【发布时间】:2018-01-11 22:43:08
【问题描述】:
我正在开发 Spring Boot 服务。
假设我有 3 个服务 A、B、C,每个服务都有 dev 和 prod 配置文件。现在我将这些服务的配置保存在 GIT 并使用配置服务器来获取配置。
所以当我在 prod 模式下运行 A 服务时,配置文件 A-prod.properties 正在被使用。
现在我想保留一些通用配置,所有 3 个服务都将使用它们,比如 common-prod.properties。我该怎么做?
我试过这个:
配置服务器:
spring:
cloud:
config:
server:
git:
uri: http://gitPaath/Configs.git
username: <username>
password: <pass>
cloneOnStart: true
searchPaths: "{common}"
我的属性是文件按此顺序在 Git Repo 中:
- A-prod.properties
- A-dev.properties
- B-prod.properties
- A-dev.properties
- C-prod.properties
- C-dev.properties
- common
- common-prod.propeties
- common-dev.properties
【问题讨论】:
-
你能解决这个问题吗,如果可以,请分享解决方案
-
解决方案是下面公认的答案。简单创建应用程序-
.properties 文件
标签: spring-boot spring-boot-configuration