这里只讲 nacos 配置优先级

spring:
  application:
    name: star
  profiles:
    active: dev
  cloud:
    nacos:
      config:
        file-extension: yml
        namespace:
        ext-config:
          - data-id: e.yml
            group: default
            refresh: true
        shared-dataids: sa.yml,sb.yml
        refreshable-dataids: r.yml

这里列出三类配置文件:

a:   star-dev.yml

b:   e.yml

c:      sa.yml,sb.yml

优先级从高到低, a > b > c,高优先级会覆盖低优先级。nacos 配置下,如无特殊配置,本地配置不会生效。

若要本地配置生效,需要在 star-dev.yml 中作如下配置,这三个配置是矛盾的,根据需要选择其中配置

spring:
  cloud:
    config:
      allow-override: true     // 允许nacos被本地文件覆盖
      override-none: true     // nacos不覆盖任何本地文件
      override-system-properties: true   // nacos 覆盖系统属性。注意本地配置文件不是系统属性

  

 

相关文章:

  • 2021-10-26
  • 2021-05-05
  • 2021-11-30
  • 2021-09-21
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2021-06-17
  • 2021-11-15
  • 2021-06-18
  • 2021-08-30
相关资源
相似解决方案