1.
@SpringBootApplication
It is a composite annotation, in fact, for springboot applications, the most important thing is that there are only three
@Target (Elementtype.type) @Retention (retentionpolicy.runtime) @Documented @inherited
//Three of the most important @Configuration @enableautoconfiguration@componentscan
public @interface springbootapplication{...}
It's too cumbersome to write three annotation at a time
@Configuration @enableautoconfiguration@componentscan Public class demoapplication { publicstaticvoid main (string[] args) { Springapplication.run (springboot01application. class , args);} }
Can simplify, write a @springbootapplication one-stop compound
@SpringBootApplication Public class demoapplication { publicstaticvoid main (string[] args) { Springapplication.run (springboot01application. class , args);} }
2. @ComponentScan
Function: Automatically scans and loads eligible component or bean definitions, then loads into containers
3, @EnableAutoConfiguration, is also a composite annotation
@Target (Elementtype.type) @Retention (rententionpolicy.runtime) @ Documented@inherited@autoconfigurationpackage@import (enableautoconfigurationimportselector.class) public @interface enableautoconfiguration{...}
The most critical is @import, which loads all eligible @configuration configurations into the IOC container created and used by the current springboot.
With the support of the original tool class Springfactoriesloader of the spring framework, @EnableAutoConfiguration can achieve "intelligent" automation configuration.
--End--to be continued ~
Spring Boot Learning Summary (ii)--some basic points about @springbootapplication