Open iNikem opened 6 years ago
As this is throwing an IllegalStateException
, an extension of CacheManagerValidator
in the auto-configuration looks probably the best route.
Closing in favour of PR #13916
Blocked on this issue.
I believe that this issue can be unblocked as the referenced issue has been fixed in 6.2.0-M2
. We've decided to re-throw the usual NoUniqueBeanDefinitionException
with additional information. This leads a demo app to fail as follows:
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.cache.CacheManager' available: no CacheResolver specified and expected a single CacheManager bean, but found 3: [firstCacheManager,secondCacheManager,thirdCacheManager] - mark one as primary or declare a specific CacheManager to use.
at org.springframework.cache.interceptor.CacheAspectSupport.afterSingletonsInstantiated(CacheAspectSupport.java:279) ~[spring-context-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1050) ~[spring-beans-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:970) ~[spring-context-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625) ~[spring-context-6.2.0-SNAPSHOT.jar:6.2.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) ~[spring-boot-3.3.0-20240429.120045-407.jar:3.3.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:457) ~[spring-boot-3.3.0-20240429.120045-407.jar:3.3.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.0-20240429.120045-407.jar:3.3.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1364) ~[spring-boot-3.3.0-20240429.120045-407.jar:3.3.0-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1353) ~[spring-boot-3.3.0-20240429.120045-407.jar:3.3.0-SNAPSHOT]
at com.example.demo.DemoApplication.main(DemoApplication.java:15) ~[classes/:na]
Process finished with exit code 1
Looking at NoUniqueBeanDefinitionFailureAnalyzer
it backs off if the description
is null
. It looks like that's the case here as it doesn't find a matching nested cause. In this case, the bean lookup attempt is done programmatically, so there isn't a UnsatisfiedDependencyException
to provide the injection points. Perhaps this rule can be relaxed a bit to process NoUniqueBeanDefinitionException
in a generic fashion?
I guess we're still blocked until we've upgraded to Framework 6.2. I'll move this into 3.x though.
My Spring Boot application failed today:
I kinda understand what happened, but a proper
FailureAnalyzer
which could tell me where those multipleCacheManagers
were defined would be of great help :)