SPring 引导服务之间的共享配置(在 git)

Shared Config(at git) between SPring Boot Services

我正在开发 spring 引导服务。

假设我有 3 个服务 A、B、C,每个都有开发和生产配置文件。现在我将这些服务的配置保存在 GIT 并使用配置服务器获取配置。

所以当我 运行 prod 模式下的服务时,正在使用配置文件 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 回购中:

- 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

您可以将服务之间的所有共享属性放在 application-<profile>.properties 文件中。

在您的情况下,制作 application-prod.propertiesapplication-dev.properties 文件并将这些文件放在根文件夹或配置服务器可搜索的任何文件夹中。

您可以在 here 的 "Sharing Configuration With All Applications" 部分找到更多详细信息。