Annotation @SpringBootApplication explains

@SpringBootApplication

@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @enableAutoConfiguration // The annotation under spring-context is used to scan the specified class @ComponentScan(excludeFilters = {@filter (type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) }) public @interface SpringBootApplication { }Copy the code

The official explanation is that the class provides the Spring Boot application @Configuration. Can be used as an alternative to the Spring standard @Configuration annotation so that configurations can be found automatically. Applications should contain only one @SpringBootConfiguration, which most conventional SpringBoot applications will inherit from @SpringBootApplication.

@EnableAutoConfiguration

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {	
}
Copy the code

The official explanation enables automatic configuration of the Spring Application Context, trying to guess and configure the beans needed. Auto-configuration classes are typically based on the classpath and the beans defined. The package of a class annotated with @enableAutoConfiguration (usually via @SpringBootApplication) has a specific meaning and is often used as the “default.” For example, it is used when scanning the @Entity class. It is generally recommended that you place @EnableAutoConfiguration in the root package so that all subpackages and classes can be searched. Auto-configuration classes are regular Spring configuration beans. They use the SpringFactoriesLoader mechanism to locate (type this class). In general, auto-configuration beans are @conditional beans (most often annotated with @conditionalonClass and @conditionalonmissingBean).

@AutoConfigurationPackage

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import(AutoConfigurationPackages.Registrar.class)
public @interface AutoConfigurationPackage {
}
Copy the code

The official explanation Instructions include an annotated class package AutoConfigurationPackages registration should be used.

AutoConfigurationImportSelector

public class AutoConfigurationImportSelector
	implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware,
	BeanFactoryAware, EnvironmentAware, Ordered
Copy the code

Where interface DeferredImportSelector is an annotation definition in a spring-context. Public Interface DeferredImportSelector extends ImportSelector Where @import indicates one or more @Configuration classes to be imported. Said import processing in @ EnableAutoConfiguration class AutoConfigurationImportSelector is handled by @ EnableAutoConfiguration modified class.

@SpringBootConfiguration

Mainly used to identify the use of @SpringBootApplication