Config 入门教程 - 中级篇
上篇 - Config 入门教程(基础篇)
前言
版本说明
在下面的的教程中,使用的 Spring Cloud 版本是 Finchley.RELEASE,对应的 Spring Boot 版本是 2.0.3,特别声明除外。
Config 使用技巧
本地参数覆盖远程参数
在某些时候需要使用当前系统的环境变量或者是应用本身设置的参数而不是使用远程拉取的参数,此时 Config Client 可以使用如下配置:
官方 Bug 解决方案:
- https://github.com/spring-cloud/sprmg-cloud-config/issues/651
- https://github.com/spring-cloud/spring-cloud-config/issues/359
1 | spring: |
- overrideNone:当 allowOverride 为 true 时,overrideNone 设置为 true,代表外部配置的优先级更低,而且不能覆盖任何已存在的属性源,默认为 false
- allowOverride:标识 overrideSystemProperties 属性是否启用,默认为 true,设置为 false 表示禁止用户的个性化设置
- overrideSystemProperties:用来标识外部配置是否能够覆盖系统属性,默认为 true