繁体   English   中英

如何将 spring-cloud-config 服务器指向 git repo 内的 git 文件夹

[英]How to point spring-cloud-config server to a git folder inside a git repo

请帮我解决以下问题。我想在 git repo 中为每个微服务都有一个文件夹。 请参考我在 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 开发人员只是想用引号突出显示它。

在 spring 云服务器中添加下面提到的搜索路径-

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

代替

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

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

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

spring.application.name=ms-one

spring.application.name=ms-two 

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

您需要为Spring Cloud Config Server设置下一个属性:

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

在这种情况下,您的客户端应用程序名称将用作文件夹的搜索路径。

指向您的 git repo 并在searchPaths设置子文件夹

spring.cloud.config.server.git.uri=https://github.com/sarat9/config-server-spring-boot
spring.cloud.config.server.git.searchPaths=config-repo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM