Closed Liesport758 closed 4 years ago
How about your code?
Hi , It is not recommended to dynamically modify the data connection information, but if you insist on using this function, you can refer to the following code
@Bean
@ConfigurationProperties(prefix = "spring.redis")
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory();
}
and the nacos config
spring:
redis:
host-name: 127.0.0.1
port: 6379
database: 1
springcloud alibaba 使用版本是2.2.1.RELEASE,Springcloud和Springboot都是推荐使用的版本。当在Nacos修改spring.redis.database由0修改为1,控制台有打印配置修改的日志,但请求后存储的数据还是在database=0中
Component组件 Nacos config