EnableAutoConfiguration annotation attempt to guess and configure beans that you are likely to need.
Auto-configuration classes are usually applied based on the presence or absence of, files or libraries in your classpath, beans you have defined, and properties.
Auto-configuration is always applied after user-defined beans have been registered.
The package of the class that is annotated with @EnableAutoConfiguration has specific significance and is often used as a 'default'. For example, it will be used when scanning for @Entity classes. It is generally recommended that you place @EnableAutoConfiguration in a root package so that all sub-packages and classes can be searched.
Spring boot auto configuration report
Spring boot auto configuration report shows all auto-configuration info:
First shows all the positive matches (conditions evaluated to true),
then negative matches (conditions evaluated to false),
then the exclusions,
and finally unconditional classes which will be always configured.
An auto configuration report can be generated in various ways such as –debug command line argument, -DDebug VM arg, DEBUG=true environment variable, debug=true or logging.level=true in application.properties etc.
Excluding / Reconfiguring Auto-configuration
You can manually exclude any auto-configuration that you don’t want to apply through the exclude parameter of EnableAutoConfiguration annotation.
Use excludeName parameter if you don't have access to classes; it expects an array of Strings which are the fully qualified class names.
You can exclude auto configuration via the spring.autoconfigure.exclude property, which also accept fully qualified class names.
You can reconfigure auto-configuration using various application properties.
You can find most common of such properties @ here.
You can exclude auto-configured servlets or filters making use of ServletRegistrationBean or FilterRegistrationBean.
Auto-configuration classes and Conditional beans
Auto-configuration classes are regular Spring Configuration beans. They are located using the SpringFactoriesLoader mechanism that reads auto-configuration classes from META-INF/spring.factories file. A list of all auto-configuration classes provided by Spring Boot can be found here.
You can have completely custom auto-configuration by removing @EnableAutoConfiguration annotation and manually configuring an array of auto configuring classes with the @Configuration and @Import annotations; @Import imports all the auto configuration classes.
Generally, auto-configuration beans are @Conditional beans, and we can also create one using @Configuration along with @ConditionalOn annotations over classeses, and/or a combination of @Bean along with @ConditionalOn annotations over a method. Most important @Conditional annotations are: @ConditionalOnClass, @ConditionalOnMissingClass, @ConditionalOnBean, @ConditionalOnMissingBean, @ConditionalOnProperty. There are also additional annotations such as @ConditionalOnJava, @ConditionalOnJndi, @ConditionalOnRersource, @ConditionalOnExpression, @ConditionalOnWebApplication, @ConditionalOnNotWebApplication etc.
SpringBootApplication annotation is a convenience annotation that is equivalent to declaring @Configuration, @EnableAutoConfiguration and @ComponentScan.