Entry point: @SpringBootApplication combines @Configuration, @ComponentScan and @EnableAutoConfiguration.
How candidates are found:
- Spring Boot reads the list of auto-configuration classes from META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports inside the starter JARs (older versions used spring.factories).
- Each listed class is a normal @Configuration class, but it is guarded by conditions.
Conditions decide what is applied:
- @ConditionalOnClass: only if a class is on the classpath (for example, Jackson).
- @ConditionalOnMissingBean: only if you haven't defined your own bean, which is why your configuration always wins.
- @ConditionalOnProperty: only if a property is set, such as spring.cache.type.
- @ConditionalOnWebApplication and others narrow it further.
Ordering: @AutoConfigureBefore / @AutoConfigureAfter control dependencies between auto-configurations, and user configuration is processed before auto-configuration.
Debugging: run with --debug or set debug=true to print the conditions evaluation report showing which auto-configurations matched and why others did not. You can exclude one with @SpringBootApplication(exclude = DataSourceAutoConfiguration.class).