See #31510 for background.
Consider the following failure analysis:
Parameter 1 of method sessionRepositoryFilterRegistration in org.springframework.boot.autoconfigure.session.SessionRepositoryFilterConfiguration required a single bean, but 2 were found:
- redisCacheConnectionFactory: defined by method 'redisCacheConnectionFactory' in class path resource [com/cwg/test/config/CacheConfig.class]
- redisSessionConnectionFactory: defined by method 'redisSessionConnectionFactory' in class path resource [com/cwg/test/config/RedisConfig.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Three actions are suggested:
- marking one of the beans as
@Primary - updating the consumer to accept multiple beans
- using
@Qualifierto identify the bean that should be consumed
One can be taken as redisCacheConnectionFactory and redisSessionConnectionFactory are both defined by the user. Two isn't possible as the consumer is code in org.springframework.boot that a user cannot change. A variation of 3 is possible as the injection point (which the analysis identifies incorrectly) uses @SpringSessionRedisConnectionFactory. Adding @SpringSessionRedisConnectionFactory to the user's @Bean definition fixes the problem.
I wonder if we can improve the failure analysis to only suggest actions that are (likely to be) possible, or to at least refine the wording a little to explain when each is likely to be possible.
Comment From: wilkinsona
We haven't seen many other occurrences of this sort of problem and providing more accurate guidance is likely to be harder than appears to be currently justified. Closing, for now at least.