Just an idea. How about having an annotation processor that populates spring.factories
entries for auto configuration classes.
The processor can add entries to spring.factories
if missing.
Also, removes entries if the pointing classes do not exist or not @Configuration
.
To add entries to spring.factories
, for example, annotation processor can find a marker @AutoConfiguration
annotation. The @AutoConfiguration
annotation may have properties alias for @Configuration
.
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
public @interface AutoConfiguration {
@AliasFor(annotation = Configuration.class)
String value() default "";
@AliasFor(annotation = Configuration.class)
boolean proxyBeanMethods() default true;
}
The usage is something like:
@AutoConfiguration(proxyBeanMethods = false)
public class MyAutoConfiguration {
...
}
This would be helpful for those who need to write many auto configurations including spring-boot itself.
Comment From: wilkinsona
Thanks for the suggestion. At the moment, an auto-configuration is exactly like any other @Configuration
class, it's just typically registered with the application context in a different way. Requiring a specific @AutoConfiguration
annotation would means that this was no longer true and I think that downside outweighs any potential benefit. Thanks anyway.