Common annotations of SpringBoot

Common annotations of SpringBoot

自行收集,仅供参考

Spring Boot is built based on the Spring framework, which inherits the features and functions of Spring, and provides many new functions, such as automatic configuration, rapid construction, etc. Therefore, Spring Boot contains a large number of annotation functions, the following are some of the commonly used annotation functions:

  • @SpringBootApplication: Mark a class as the main class of the Spring Boot application, which can start the application.

  • @RestController: Marks a class as a controller for a RESTful Web service.

  • @RequestMapping: Used to map HTTP requests to methods in controllers.

  • @GetMapping: Maps HTTP GET requests to methods in the controller.

  • @PostMapping: Maps HTTP POST requests to methods in the controller.

  • @PutMapping: Maps HTTP PUT requests to methods in the controller.

  • @DeleteMapping: Maps HTTP DELETE requests to methods in the controller.

  • @PathVariable: Used to extract the variable's value from the URL.

  • @RequestParam: Used to extract the value of a variable from a request parameter.

  • @RequestBody: Used to map the body of the request to method parameters.

  • @ResponseStatus: Used to set the status code of the response.

  • @ControllerAdvice: Used to define global controller exception handlers.

  • @Autowired: Used to autowire a Bean.

  • @ComponentScan: Used to scan the specified package for components.

  • @EnableAutoConfiguration: Used to enable the automatic configuration function of Spring Boot.

  • @ConfigurationProperties: Used to map properties to classes so that properties can be easily read from configuration files.


Guess you like

Origin blog.csdn.net/IWICIK/article/details/129188323
Recommended