Annotations are used to define a class, property, or method that a program can compile. It also acts as an explanatory file. Tells the program what a class or attribute is annotated by a particular annotation and what to do about it. Annotations can be used to annotate packages, classes, methods, and variables.

1. Commonly used annotations on classes

annotations Use location instructions
@RestController In the name of the class @RestController=@Controller + @RequestBody When the front and back ends are separated, it is used to return DATA in JSON or XML format
@Controller In the name of the class Declare the current class to be a controller layer, equivalent to C (controller) in the MVC development pattern
@Service In the name of the class Declare the current class to be a business processing class that annotates the service layer and handles the business logic class
@Reporitory In the name of the class Used to annotate the data access layer
@Component In the name of the class Generic annotations that can mark any class asSpringComponents. This can be used if a Bean does not know which layer it belongs to@ComponentAnnotation annotation.
@Configuration In the name of the class It is used to declare configuration classes@ComponentAnnotations are used instead, howeverConfigurationAnnotation declaration configuration classes are more semantic
@Resource On a class name, property, or constructor parameter Both @autoWired and @autoWired can be used to assemble beans, with byType auto-injection by default
@Autowired On a class name, property, or constructor parameter Automatically import objects into classes. Injected classes are also managed by the Spring container. ByName is automatically injected by default
@RequestMapping Class name or method Used to handle request address mapping
@Transactional Class name or method Used on the method to start a transaction@TransactionalAnnotations can be
@Qualifier Class name or property Often used with @AutoWired to indicate which implementation class needs to be injected
@JsonIgnoreProperties In the name of the class Used to filter out specific fields without returning or parsing
@Transient On the properties Declare the field that does not need to be mapped to the database, do not need to save into the database when saving, virtual field

2. Common annotations to methods

annotations Use location instructions
@Bean On the way Declare a Bean and hand it over to Spring to manage.
@ReponseBody On the way After converting the object returned by the method to JSON or XML format, write the body data area of the Response object
@RequestBody Method parameter before In short, you convert a JSON string into a Java object
@PathVariable Method parameter before Map the parameters obtained from the URL to the method

3. Other commonly used notes

annotations Use location instructions
@EnableAutoConfiguration Entry class, class name Enabling Automatic Configuration
@SpringBootApplication Entry class, class name Start the entry class Application(@SpringBootApplication is considered a collection of @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations.)
@EnableScheduling Entry class, class name Used to start scheduled tasks, such as scheduled tasks
@EnableAsync Entry class, class name Enable asynchronous annotations
@ComponentScan Entry class, class name Used to scan components to see beans automatically discovered and assembled
@Aspec Entry class, class name Annotated facets that can be used to configure transactions, logging, permission validation, and so on
@ControllerAdvice In the name of the class Contains @Component, which can be scanned and handled uniformly
@ExceptionHandler On the way Indicates that the method is executed when the exception is encountered
@Value On the properties Used to get the value in the configuration file

4. To summarize

Of course, SpringBoot provides us with a lot of annotations for developers, the above article is just a summary of the common SpringBoot development process of some annotations, and a brief description of the role or purpose of their annotations.