Understanding Auto-configured Beans
Classes that implement auto-configuration are annotated with @AutoConfiguration
.
This annotation itself is meta-annotated with @Configuration
, making auto-configurations standard @Configuration
classes.
Additional @Conditional
annotations are used to constrain when the auto-configuration should apply.
Usually, auto-configuration classes use @ConditionalOnClass
and @ConditionalOnMissingBean
annotations.
This ensures that auto-configuration applies only when relevant classes are found and when you have not declared your own @Configuration
.
You can browse the source code of spring-boot-autoconfigure
to see the @AutoConfiguration
classes that Spring provides (see the META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
file).