SpringBoot annotation method

Basic annotation 

# Annotate on the class

@Service: Indicates that this is a business layer bean

@Controller: Indicates that this is a control layer bean

@Repository:  Indicates that this is a data access layer bean

@Component:  Indicates a general bean, if the value is not written, the default is the first letter of the class name is lowercase

# inject by type

@Autowired: Annotate class member variables, methods, and constructors to let spring complete the work of bean automatic assembly; the default attribute required=true

#Start Annotation

@SpringBootApplication: This annotation is a combination of @ComponentScan, @SpringBootConfiguration, @EnableAutoConfiguration

@ComponentScan: Add the Configuration class scanned by SpringBoot to the program context

@SpringBootConfiguration: Allows to register additional beans or import other configuration classes in the Spring context

@EnableAutoConfiguration: Enable SpringBoot's automatic configuration mechanism

#HTTP annotations

@RequestBody: HTTP request to get the request body (processing complex data, such as JSON)

@RequestHeader: HTTP request to get the request header

@RequestParam: HTTP request to obtain request parameters (handle simple data, key-value pairs)

@SessionAttribute: HTTP request to get the session

@RequestAttribute: HTTP request to get the Attribute of the request (such as some temporary data manually set by filters and interceptors)

@MatrixAttribute: HTTP requests to obtain matrix variables allow us to use special rules to add parameters after the URL path (semicolons distinguish different parameters, commas add multiple values ​​for parameters)

@PathVariable: HTTP request to get the path fragment

@CookieValue: HTTP request to get cookie

Guess you like

Origin blog.csdn.net/qq_53376718/article/details/129743783