If Spring Boot auto configuration were a matchmaker it would be the kind that assumes everyone wants to be paired with sensible defaults and then quietly rearranges your beans while you are writing business logic. The framework uses a few well documented tricks to guess what you need based on the classpath and what you already declared as beans.
The wiring starts when you use @EnableAutoConfiguration
or the convenient @SpringBootApplication
. That triggers an import selector that asks SpringFactoriesLoader
to read META-INF/spring.factories
and produce a list of candidate auto configuration classes.
Each candidate is a normal @Configuration
class wrapped in conditions. The two most common guards are @ConditionalOnClass
and @ConditionalOnMissingBean
. The first checks that a supporting library is actually on the classpath. The second says the auto configuration will step back if you already provided the bean. This is how the framework manages to be useful without being bossy.
Auto configuration uses ordering hints like @AutoConfigureAfter
and the entries in spring.factories
to decide which config wins when multiple candidates want to provide the same bean type. You can also exclude classes globally with the spring.autoconfigure.exclude
property or by passing exclude arguments to @SpringBootApplication
or @EnableAutoConfiguration
.
Spring Boot is generous but not psychic. If the defaults are not what you expected you have several reliable options.
@ConditionalOnMissingBean
and usually causes the auto configuration to step aside.@ConditionalOnProperty
to flip features on or off via configuration without touching code. Great for feature flags and toggles.@ImportAutoConfiguration
to load a specific subset of auto configurations instead of trusting the whole enchilada.spring.autoconfigure.exclude
or the exclude attribute on your startup annotation when you need surgical precision.When a bean appears out of nowhere the fastest diagnostic is debug logging. Turn on debug for org.springframework.boot.autoconfigure
and you will see which auto configuration classes ran and which conditions passed. Reading the actual auto configuration class is also practical. It typically spells out the conditions that allowed it to win.
META-INF/spring.factories
when investigating ordering or unexpected registrations.Auto configuration is modular, conditional, and driven by metadata in spring.factories
. It exists to let you focus on business logic rather than plumbing. When it guesses wrong use the exclusion and conditional annotations that Spring Boot hands you. And if all else fails feel free to blame the keyboard while you check the logs.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.