• 集成spring cloud config后优先使用本地配置


    集成spring clound config时默认情况下,远程配置会覆盖本地配置(除非是命令行参数)。
    如果要优先使用本地配置,需要在远程配置中加入一些参数。

    spring.cloud.config.allow-override=true(允许被覆盖)
    spring.cloud.config.override-none=true (远程配置不覆盖任何本地配置)
    spring.cloud.config.override-system-properties=false (远程配置不覆盖系统属性与环境变量,但是会覆盖本地配置文件)
    
    • 1
    • 2
    • 3

    注意:只有设置spring.cloud.config.allow-override=true时,spring.cloud.config.override-none和spring.cloud.config.override-system-properties才会生效。

    原文档说明如下:

    Overriding the Values of Remote Properties
    The property sources that are added to you application by the bootstrap context are often “remote” (e.g. from a Config Server), and by default they cannot be overridden locally, except on the command line. If you want to allow your applications to override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting spring.cloud.config.allowOverride=true (it doesn’t work to set this locally). Once that flag is set there are some finer grained settings to control the location of the remote properties in relation to System properties and the application’s local configuration: spring.cloud.config.overrideNone=true to override with any local property source, and spring.cloud.config.overrideSystemProperties=false if only System properties and env vars should override the remote settings, but not the local config files.

  • 相关阅读:
    C#对SQLite的常用操作
    java-php-python-基于ASP.NETMVC的苗木购销系统计算机毕业设计
    Apache Hive 数据掩码函数教程
    leetcode92-Reverse Linked List II
    从源码分析UUID类的常用方法
    Docker 实现 MySQL 一主一从配置
    【Proteus仿真】【STM32单片机】电蒸锅温度控制系统
    DDoS攻击和CC攻击
    华为机试 - 欢乐的周末
    异步FIFO设计的仿真与综合技术(1)
  • 原文地址:https://blog.csdn.net/crazyman2010/article/details/125912619