Spring Cloud Config—Git搜索路径中的占位符

237 阅读1分钟

Spring Cloud Config服务器还支持具有{application}和{profile}(以及{label}(如果需要))占位符的搜索路径。例:

spring: cloud: config: server: git: uri: https://github.com/spring-cloud-samples/config-repo searchPaths: '{application}' 在资源库中搜索与目录(以及顶级)相同名称的文件。通配符在具有占位符的搜索路径中也是有效的(搜索中包含任何匹配的目录)。

力拉入Git存储库 如前所述Spring Cloud Config服务器克隆远程git存储库,如果某种方式本地副本变脏(例如,通过操作系统进程更改文件夹内容),则Spring Cloud Config服务器无法从远程存储库更新本地副本。

要解决这个问题,有一个force-pull属性,如果本地副本是脏的,将使Spring Cloud Config Server强制从远程存储库拉。例:

spring: cloud: config: server: git: uri: https://github.com/spring-cloud-samples/config-repo force-pull: true 如果您有多个存储库配置,则可以为每个存储库配置force-pull属性。例:

spring: cloud: config: server: git: uri: https://git/common/config-repo.git force-pull: true repos: team-a: pattern: team-a-* uri: http://git/team-a/config-repo.git force-pull: true team-b: pattern: team-b-* uri: http://git/team-b/config-repo.git force-pull: true team-c: pattern: team-c-* uri: http://git/team-a/config-repo.git 注意 force-pull属性的默认值为false。

源码来源:http://minglisoft.cn/honghu/technology.html