Add @AutoConfiguration annotation

This annotation can be used to mark auto-configurations with a dedicated
annotation. Under the hood, it's a standard @Configuration with
proxyBeanMethods set to false.

Closes gh-29870
This commit is contained in:
Moritz Halbritter
2022-02-16 11:50:51 +01:00
parent 8ae77659cd
commit 100f80d073
2 changed files with 53 additions and 1 deletions

View File

@@ -12,7 +12,8 @@ TIP: A https://github.com/snicoll-demos/spring-boot-master-auto-configuration[de
[[features.developing-auto-configuration.understanding-auto-configured-beans]]
=== Understanding Auto-configured Beans
Under the hood, auto-configuration is implemented with standard `@Configuration` classes.
Under the hood, auto-configuration is implemented with the `@AutoConfiguration` annotation.
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`.