I've recently upgraded from Spring Boot 2.5.x to 2.7.x (now on spring-core 5.3.30) which by default disables Spring's support for cyclic dependencies. For beans that are defined at application startup (through component scanning) this results in a nice error message and the application fails to start, as it should.
However, when a bean implements ApplicationContextAware
and in its setApplicationContext()
method uses the ApplicationContext#getBeansOfType(Class<T> type)
method to look up all beans of a given type, any beans implementing the given type but having a (non-@Lazy
) dependency to the current bean appear to be silently omitted from the returned list. I'd expect an exception to be thrown instead.
Comment From: snicoll
Thanks for the report. Please see https://github.com/spring-projects/spring-framework/issues/28412 which provides an explanation and what you should be using.