栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

集成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 (远程配置不覆盖系统属性与环境变量,但是会覆盖本地配置文件)

注意:只有设置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.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1024181.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号