Cor*_*ght 3 git spring-cloud spring-cloud-config
请帮我解决以下问题。我想在 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
Run Code Online (Sandbox Code Playgroud)
小智 7
是可以解决的。技巧是给出{application}不带引号的搜索路径,如下所示。这有点棘手,因为 Spring 文档将其称为 '{application}' ,可能 Spring 开发人员只是想用引号突出显示它。
在 Spring Cloud 服务器中添加下面提到的搜索路径-
spring.cloud.config.server.git.search-paths={application}
Run Code Online (Sandbox Code Playgroud)
代替
spring.cloud.config.server.git.search-paths='{application}'
Run Code Online (Sandbox Code Playgroud)
这将搜索路径(在服务器端)设置为等于客户端应用程序名称的名称。
现在,如果您的微服务/应用程序 - 它们应该具有如下 spring.application.name -
spring.application.name=ms-one
Run Code Online (Sandbox Code Playgroud)
和
spring.application.name=ms-two
Run Code Online (Sandbox Code Playgroud)
他们将查看 ms-one 和 ms-two 各自文件夹中的属性文件。
| 归档时间: |
|
| 查看次数: |
5053 次 |
| 最近记录: |