-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Auto configuration of MethodValidationPostProcessor in class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration requires instance of Environment. Since the envirnonemt does not have @Lazy annotation it triggers autowire candidate resolution with lazyInit=true which in turn results in initialization of (at least) FactoryBeans.
Bean post processors should NOT use autowiring since the beans created just to check that they do not implement Environment are later not eligible for all other bean post processors - which is actually confirmed in log by lots of:
Bean 'xxx' of type [XXX] is not eligible for getting processed by all BeanPostProcessors
I have implemented custom ImportBeanDefinitionRegistrar. When I use it like this:
@SpringBootApplication
@Import(GenesysRegistrar.class)
public class IntegrationServer {
...
}everything works fine. But if I create my own auto-configuration class:
@Configuration
@Import(GenesysRegistrar.class)
public class GenesysAutoConfiguration {
}then bean definitions registered by GenesysRegistrar are created BEFORE MethodValidationPostProcessor during search for bean implementing Environment interface.