首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将spring-cloud-config服务器指向git代码库中的git文件夹

如何将spring-cloud-config服务器指向git代码库中的git文件夹
EN

Stack Overflow用户
提问于 2020-03-03 12:38:59
回答 3查看 2K关注 0票数 1

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

代码语言:javascript
复制
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
EN

回答 3

Stack Overflow用户

发布于 2020-04-19 10:51:09

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

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

代码语言:javascript
复制
spring.cloud.config.server.git.search-paths={application}

而不是

代码语言:javascript
复制
spring.cloud.config.server.git.search-paths='{application}'

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

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

代码语言:javascript
复制
spring.application.name=ms-one

代码语言:javascript
复制
spring.application.name=ms-two 

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

票数 4
EN

Stack Overflow用户

发布于 2020-03-04 00:07:38

您需要为Spring Cloud Config Server设置next属性

代码语言:javascript
复制
spring.cloud.config.server.git.search-paths='{application}'

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

票数 2
EN

Stack Overflow用户

发布于 2021-03-11 21:36:45

指向git代码库,并在searchPaths中设置子文件夹

代码语言:javascript
复制
spring.cloud.config.server.git.uri=https://github.com/sarat9/config-server-spring-boot
spring.cloud.config.server.git.searchPaths=config-repo
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60500158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档