Ali*_*ouf 2 spring-boot spring-cloud-config
我正在尝试为我的配置存储库建立一个文件夹结构。
\nroot\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 serviceA\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 application-dev.properties\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 application-prod.properties\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 serviceB\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 application-dev.properties\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 application-prod.properties\nRun Code Online (Sandbox Code Playgroud)\n在我的配置服务器中,我有以下内容application.yml
server:\n port: 8081\nspring:\n application:\n name: cloud-config-server\n cloud:\n config:\n server:\n monitor:\n github:\n enabled: true\n gitee:\n enabled: true\n git:\n password: ${PASSWORD}\n username: ${USERNAME}\n uri: ${LINK_TO_CONFIG}\n default-label: master\n search-paths: serviceA, serviceB\nRun Code Online (Sandbox Code Playgroud)\n当运行服务器并请求时http://localhost:8081/serviceA/prod,http://localhost:8081/serviceB/prod我得到相同的结果
{\n "name":"serviceA",\n "profiles":[\n "prod"\n ],\n "label":null,\n "version":"9df32c9dbd11be65e892caf878ddc8d16906a849",\n "state":null,\n "propertySources":[\n {\n "name":"GITHUB_URI/springcloudconfigrepo/serviceB/application-prod.properties",\n "source":{\n "profile":"some-service-prod"\n }\n },\n {\n "name":"GITHUB_URI//springcloudconfigrepo/serviceA/application-prod.properties",\n "source":{\n "profile":"another-service-prod"\n }\n }\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n我的问题是,如何仅获取 serviceA (或 serviceB)的属性?
\n我在github上的spring cloud配置服务器在这里
\n您需要将配置设置为searchPaths您的应用程序名称。
配置应该如下所示:
spring:
cloud:
config:
server:
git:
uri: ${LINK_TO_CONFIG}
searchPaths: '{application}'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |