Commonly used annotations in learning (to be updated)

Commonly used annotations in learning (to be updated)

(Note: This article collects some information from other bloggers for your own learning and use. If there are any mistakes, please comment and correct them)

one. springboot

1.Annotations of Application class

Mapperscan: scan mapper package
springbootApplication: is the core annotation of the Sprnig Boot project, the purpose is to enable automatic configuration

Insert image description here

2. Add the bean of the ioc container

Insert image description here
Insert image description here
Insert image description here

@Qualifier:

Insert image description here

3.@RestController 和@RequestMapping(“/boots”)

Insert image description here

4. Test

4.1

Insert image description here

@RunWith(SpringRunner.class)

If the Test test class in the Spring project uses injected classes, such as @Autowired injected classes or spring-managed beans, the spring container needs to be run before the test class is run, and this @RunWith(SpringRunner.class ) annotation is to run the spring container first and then start running the test class.

5. Some notes collected by the website

Insert image description here

Insert image description here

Insert image description here

Insert image description here
Insert image description here
Insert image description here

Insert image description here

6.@ConfigurationProperties

Insert image description here

Insert image description here

7.@EnableAutoConfiguration(): Instantiate classes in dependent packages

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}): Instantiate the DataSource class

Insert image description here

Insert image description here

8. Some notes on pojo

@AllArgsConstructor: Automatically generate parameterized constructor
@NoArgsConstructor: Automatically generate parameterized constructor
@Data: Automatically generate get and set methods

Insert image description here

two. other

1.servlet configuration path @webservlet

Insert image description here

three. SSM

1. Relevant understanding of aop

Insert image description here
Insert image description here

Insert image description here

Insert image description here
Insert image description here

2. Exception interception annotations

Insert image description here
Insert image description here

3. Various annotations for configuration classes

@Configuration: Add the desired component to the container and tell spring that this is a configuration class
@PropertySource("classpath:db.properties"): Connect the configuration file

@Import({jdbcConfig.class, mybatisConfig.class}): Import class

@EnableAspectJAutoProxy //Annotation development aop

Insert image description here

4.@Bean

Insert image description here
Insert image description here

5.Springmvc

@EnableWebMvc: is an annotation that uses Java annotations to quickly configure Spring Webmvc

Insert image description here

3.MapperScan: mapper package scan

Insert image description here

四.Springcloud

1.@RefreshScope: nacos configuration hot update

2. @Slf4j

The annotation is equivalent to private final Logger logger = LoggerFactory.getLogger(current class name.class);

Then the function of the code is the same: it is to initialize the log object using the specified class. When the log is output, the class where the log information is located can be printed out.

Insert image description here

3.ConfigurationProperties

Insert image description here

4.EnableFeignClients(clients = UserClient.class, defaultConfiguration = FeignClientConfiguration.class)

Insert image description here

5.@LoadBalanced

Insert image description here

Insert image description here

6.@FeignClient(“userservice”)

Insert image description here

7.SpringAMQP

Insert image description here

Guess you like

Origin blog.csdn.net/m0_71106830/article/details/130661704