@SpringBootApplication
注释用于标记一个类为配置类,其可以声明一个或多个@Bean
方法,
同时触发自动装配@EnableAutoConfiguration
和组件扫描@ComponentScan
。
这是一个方便使用的注释(@Annotation),相当于同时声明了@Configuration
、@EnableAutoConfiguration
和@ComponentScan
注释。
package org.springframework.boot.autoconfigure;
@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 {
}