首页 > 解决方案 > Spring Cloud 配置服务器中是否有多个 GIt 主机?

问题描述

由于最近 Microsoft 的 Azure 服务中断,我们的团队正在集思广益,为我们的应用程序添加冗余和容错。

Spring.IO的文档中,有多种方法可以一起使用 Git、SVN 或 vault,但我对使用两个 Git 主机感兴趣。

设置复合配置文件可能是我正在寻找的东西,但这听起来像是我试图覆盖所有列出的存储库中的值并且我正在寻找一个完整的故障转移选项。

我的用例是如何配置配置服务器,以便如果主机出现故障并且我们无法检索配置文件以故障转移到我们的第二个 GIT 主机。

这可能吗?配置会是什么样子?

我的猜测是这样的订购。

  spring:
    profiles:
      cloud:
        config:
          server:
            git:
              uri: bitbucket.com
              order: 1
            git:
              uri: github.com
              order: 1

标签: springconfigurationconfigspring-cloudspring-cloud-config

解决方案


答案是使用复合特征

spring:
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
        -
          type: git
          uri: file:///path/to/rex/git/repo
        -
          type: git
          uri: file:///path/to/walter/git/repo

推荐阅读