Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between @SpringBootConfiguration vs @Configuration?

What is the difference between @SpringBootConfiguration and @Configuration? I cannot find much details on it.

like image 875
Faraz Avatar asked Jul 06 '19 00:07

Faraz


Video Answer


1 Answers

According to Spring Boot Document (hierarchy below), we can say that @Configuration is a part of @SpringBootConfiguration which ultimately have @SpringBootApplication

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

}

@Configuration

    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Component
    public @interface Configuration {
}
like image 85
Romil Patel Avatar answered Oct 01 '22 17:10

Romil Patel