SpringBootConfiguration

SpringBootConfiguration

@SpringBootConfiguration@Configuration有什么区别?我找不到很多细节。

最佳答案

根据Spring Boot Document(下面的层次结构),我们可以说@Configuration@SpringBootConfiguration的一部分,而@SpringBootApplication最终具有ojit_code

@SpringBootApplication
-------> @SpringBootConfiguration
       -------> @Configuration

@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 {
...}

@SpringBootConfiguration
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
public @interface SpringBootConfiguration {

}

@配置
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Component
    public @interface Configuration {
}

10-07 13:20