Spring Cloud 配置版本控制 [英] spring cloud config versioning

查看:36
本文介绍了Spring Cloud 配置版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 application.properties 文件中拥有所有通用属性.版本特定的属性位于 github 的 version1 和 version2 文件夹中.

I have all the common properties in application.properties file. version specific properties are in version1 and version2 folders in github.

order-service(base folder)
    application.properties
    version1
        app-dev.properties
    version2
        app-dev.properties

如何在 application.yml 文件中设置配置以确保云配置服务器在命中 version1 url 时返回 version 1 props 以及常用 props.下面是我现在从基本文件夹中获取 props 的配置以及如何是否可以修改以达到上述目的.

How can I set the config in application.yml file to ensure cloud config server returns version 1 props along with with common props when version1 url is hit.Below is the config that I have now to fetch props from base folder and how could it be modified to achieve the above.

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.company.com/orders-properties
          username: orders
          password: orders
          search-paths: order-service

推荐答案

如果我理解正确,这就是您所需要的.

If I understood correctly this is what you need.

假设您有两个名为 app-dev-v1app-dev-v2 的应用.

Lets say you have two apps called app-dev-v1 and app-dev-v2.

您需要在资源文件夹中添加 bootstrap.yml 文件,并在两个应用程序上添加此属性.

You need to add a bootstrap.yml file inside the resources folder and add this property on both the apps.

对于 app-dev-v1

spring:
  application:
    name: app-dev-v1

对于 app-dev-v2

spring:
  application:
    name: app-dev-v2

在存储库中,您可以在 version1 和 version2 文件夹中拥有像这样的 .yml 或 .properties 文件.

In the repository you can have a .yml or .properties file like this inside version1 and version2 folder.

app-dev-v1.ymlapp-dev-v2.yml

同样对于配置服务器,您需要添加搜索路径:

Also for config server you need to add the search paths:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.company.com/orders-properties
          username: orders
          password: orders
          search-paths: order-service,version*

这篇关于Spring Cloud 配置版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆