Spring Boot 教程(2) Spring Boot 启动类上注解 @SpringBootApplication
该注解是一个复合注解。
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
excludeFilters = {@Filter(
type = FilterType.CUSTOM,
classes = {TypeExcludeFilter.class}
), @Filter(
type = FilterType.CUSTOM,
classes = {AutoConfigurationExcludeFilter.class}
)}
)
public @interface SpringBootApplication {
}
由@EnableAutoConfiguration、@SpringBootConfiguration、@ComponentScan组合而成,默认扫描启动类所在包下的所有bean。如果要自定义扫描路径需要在启动类上使用@ComponentScan注解去指定特定的扫描路径。