The new way to register beans in a functional way is coming to Spring Framework 7:
spring-projects/spring-framework#18353 (comment)
We need to add a new validation:
- for every class that implements
BeanRegistrar
, there should be an @Import(..)
for that class in some configuration
- quick fix should allow users to add this
@Import
to existing configuration classes, or create a new configuration class with that @Import
- difficulty might be that a config class already has an
@Import
annotation, in which case the bean registrar type should be added to that @Import
annotation for that config class
@Configuration
@Import(MyBeanRegistrar.class)
public class MyConfiguration {
}
public class MyBeanRegistrar implements BeanRegistrar {
...