Question
We have SpringBoot based RestAPI for our backend
Intermittently, we see that our custom bean GlobalMethodSecurityConfiguration does not load. We see the below log message during spring startup.
We have added @Lazy annotation, but still it does not load always. More often than not, it fails.
We got lucky once, when we added a log.debug statement in the bean, and we are currently using that Jar. However, we want to fix this intermittent problem so our future builds are good, and we aren't leaving it to chance.
31-01-2022 18:41:59.339 [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization - Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$bc17a88f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Answer
The @Lazy annotation seems misused, in this context. Is Spring Security already on the application's classpath? I recommend that you always have an integration test in place that checks your Spring configuration.