开发者社区 问答 正文

RefreshScope 添加到Controller类上, nacos 修改配置不生效

RefreshScope 添加到Controller类上, nacos 修改配置不生效

展开
收起
一人吃饱,全家不饿 2021-02-01 20:09:20 4678 分享 版权
来自: 阿里开源
1 条回答
写回答
取消 提交回答
  • @RefreshScope属于spring-cloud的注解,要使用spring-cloud-starter-alibaba-nacos-config-0.2.1.RELEASE并且在bootstrap.properties 中使用如下配置

    # 默认true
    spring.cloud.nacos.config.refresh.enabled=true
    
    ###############################################
    # 自定义 Data Id 的配置
    spring.cloud.nacos.config.ext-config[0].data-id=data_id.yaml
    # 默认false
    spring.cloud.nacos.config.ext-config[0].refresh=true
    ###############################################
    
    

    或者可以使用 spring.cloud.nacos.config.shared-dataids、spring.cloud.nacos.config.refreshable-dataids

    2021-02-01 20:09:27
    赞同 展开评论
问答分类:
问答地址: