The core of Spring Boot
Entry class and @SpringBootApplication
Spring Boot projects generally have an entry class of *Application , and there will be a main method in the entry class, which is the entry method of a standard Java application.
The @SpringBootApplication annotation is the core annotation of Spring Boot , which is actually a combined annotation:
This annotation mainly combines the following annotations:
1. @SpringBootConfiguration : This is the configuration annotation of the Spring Boot project, which is also a combined annotation:
It is recommended to use @SpringBootConfiguration instead of @Configuration in Spring Boot projects2. @EnableAutoConfiguration : Enable automatic configuration, this annotation will cause Spring Boot to automatically configure the configuration items of the project according to the jar package that the project depends on :
a) For example: we add the dependency of spring-boot-starter-web , the dependency of SpringMVC will be introduced into the project, and Spring Boot will automatically configure tomcat and SpringMVC
3. @ComponentScan : By default , the sibling directory of the class where @SpringBootApplication is located and its subdirectories are scanned .