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)
This error message typically indicates that the bean in question (in this case, GlobalMethodSecurityConfiguration) is not being loaded by Spring Boot as expected.
There are a few possible reasons for this:
The bean is not in the package scanned by Spring Boot. If you are using the @SpringBootApplication annotation, it scans for beans in the same package as the annotated class, as well as its subpackages. So, the bean class should be located in a package that is within the same package hierarchy.
The bean is not annotated with @Configuration, which is required for it to be considered a configuration class by Spring Boot.
The bean class is not being instantiated because another configuration class is taking precedence.
You can check for these issues, If issue persist then you might want to post your application code snippet, so that I could give you more specific advice.