Several commonly used Notes on SpringBoot
Editor to share with you a few commonly used SpringBoot notes, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
Several commonly used Notes on SpringBoot
(1) @ RestController and @ Controller specify a class as an annotation for the controller and explain the difference
(2) @ RequestMapping method-level mapping annotations, which are familiar to a partner who has used Spring MVC.
(3) @ EnableAutoConfiguration and @ SpringBootApplication are class-level annotations. Automatically guess the correct configuration of spring according to the jar of maven dependency. As long as spring-boot-starter-web dependency is introduced, Spring MVC and tomcat containers will be automatically configured by default.
(4) @ Configuration class-level annotation. Generally, this annotation is used to identify the class where the main method is located and to complete the initialization of the metadata bean.
(5) @ ComponentScan class-level annotation, which automatically scans and loads all Spring components, including Bean injection, and is generally used on the class where the main method resides
(6) @ ImportResource class-level annotations, and when we have to use a xml configuration, use @ ImportResource and @ Configuration to identify the class of this file resource.
(7) @ Autowired annotation, usually combined with @ ComponentScan annotation, to automatically inject a Service or Dao-level Bean
(8) @ Component class-level annotation, which is used to identify a component. For example, if I customize a filter, I need this annotation to identify Spring Boot correctly.
How does springboot manage transactions? Just write the @ transactional annotation, which is a method transaction in a method and a class transaction in a class.
The above are all the contents of this article "several commonly used Notes on SpringBoot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!