如何将 spring-cloud-config 服务器指向 git repo 内的 git 文件夹 [英] How to point spring-cloud-config server to a git folder inside a git repo

查看:36
本文介绍了如何将 spring-cloud-config 服务器指向 git repo 内的 git 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解决以下问题.我想在 git repo 中为每个微服务都有一个文件夹.请参考我在 git repo 中的示例结构.https://github.com/tech-vishesh/config-server_properties

Please help me to resole the following problem.I would like to have a folder for each micro service in git repo. Please refer the sample structure I have inside git repo. https://github.com/tech-vishesh/config-server_properties

If we have same properties under different folder
        like
        ms-one
        |--- application.properties
        |--- application-prod.properties
        |--- application-dev.properties
        ms-two
        |--- application.properties
        |--- application-prod.properties
        |--- application-dev.properties

        we have define search path in spring cloud config bootstrap file
        spring.cloud.config.server.git.search-paths=ms-one,ms-two
        Now we have to load profile in client application then how we can load the profile?
        I have define
        spring.application.name=application
        spring.profiles.active=dev
        but how to define which folder.

    Current spring boot version 2.2.5

推荐答案

可以解决.诀窍是给搜索路径 {application} 不带引号,如下所示.这有点棘手,因为 spring 文档将其称为 '{application}' ,可能 spring 开发人员只是想用引号突出显示它.

It can be solved. The trick is to give search-path {application} without quotes as given below. It was a little tricky as spring documentation mentions it as '{application}' , probably spring developers just wanted to highlight it with quotes.

在spring cloud server中添加下面提到的搜索路径-

In spring cloud server add below mentioned search path-

spring.cloud.config.server.git.search-paths={application}

代替

spring.cloud.config.server.git.search-paths='{application}'

这将搜索路径(在服务器端)设置为等于客户端应用程序名称的名称.

This sets the search path(on server side) equal to the name of client application name .

现在,如果您的微服务/应用程序-它们应该具有如下所示的 spring.application.name-

now if your microservices/applications- they should have spring.application.name as below-

spring.application.name=ms-one

spring.application.name=ms-two 

他们将查看 ms-one 和 ms-two 各自文件夹中的属性文件.

they would be looking at the properties file within their respective folders of ms-one and ms-two.

这篇关于如何将 spring-cloud-config 服务器指向 git repo 内的 git 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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