alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.83k stars 8.31k forks source link

2.2.1.RELEASE,配置修改不生效 #1726

Closed Liesport758 closed 4 years ago

Liesport758 commented 4 years ago

springcloud alibaba 使用版本是2.2.1.RELEASE,Springcloud和Springboot都是推荐使用的版本。当在Nacos修改spring.redis.database由0修改为1,控制台有打印配置修改的日志,但请求后存储的数据还是在database=0中

Component组件 Nacos config

mercyblitz commented 4 years ago

How about your code?

yuhuangbin commented 4 years ago

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