You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to connect multiple redis on springboot, and I have defined a custom prefix for creating my own LettuceConnectionFactory :
@ConfigurationProperties(prefix = "module.sr-opersession.redis")
@Bean(name = "Module_OperSession.ConnectConfig")
public RedisProperties _OperSessionConnectConfig() {
return new RedisProperties();
}
But when running springboot, there is an error.
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration required a single bean, but 2 were found:
- Module_OperSession.ConnectConfig: defined by method '_OperSessionConnectConfig' in class path resource [com/stoprefactoring/once/module/_OperSession/_OperSessionRedis.class]
- spring.data.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties: defined in unknown location
The reason is that org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration automatically uses RedisProperties.
And the spring.data.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties defined like this:
@ConfigurationProperties(prefix = "spring.data.redis")
public class RedisProperties {
...
}
I think spring.data.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties should add @Primary
or LettuceConnectionConfiguration change the setting of @ConditionalOnProperty
or LettuceConnectionConfiguration add @qualifier for RedisProperties properties
The text was updated successfully, but these errors were encountered:
I'm afraid that we don't consider this to be a bug. There are many places in Spring Boot where we inject a …Properties class and expect there to be a single candidate. We also don't consider the …Properties classes to be public API:
The properties that map to @ConfigurationProperties classes available in Spring Boot, which are configured through properties files, YAML files, environment variables, and other mechanisms, are public API but the accessors (getters/setters) of the class itself are not meant to be used directly.
You should define your own @ConfigurationProperties class that meets your specific needs.
We hope to improve support for auto-configuring multiple beans, such as multiple Redis connections in the future. Please see #22403 and #15732 for details.
Springboot version: 3.3.1
I want to connect multiple redis on springboot, and I have defined a custom prefix for creating my own LettuceConnectionFactory :
But when running springboot, there is an error.
The reason is that
org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration
automatically usesRedisProperties
.And the
spring.data.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties
defined like this:I think
spring.data.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties
should add@Primary
or LettuceConnectionConfiguration change the setting of
@ConditionalOnProperty
or LettuceConnectionConfiguration add @qualifier for RedisProperties properties
The text was updated successfully, but these errors were encountered: