【发布时间】:2018-07-05 02:10:39
【问题描述】:
我们在 Java 8 上为简单的应用程序 helloworldclient 使用 Spring Cloud Consul Config 1.3-RELEASE,与 bootstrap.xml 一起按预期工作...
spring:
cloud:
consul:
token: xxxx-xxxx-xxxx-xxxx
discovery:
enabled: true
register: true
service-name: helloworldclient-xyz123
health-check-url: ${HEALTH_CHECK_URL}
config:
profile-separator: '/'
enabled: true
format: yaml
host: ${CONSUL_HTTP_ADDR}
port: 8500
application:
name: helloworldclient
使用配置文件dev 运行应用程序,这是从/env 加载的配置...
"consul:config/helloworldclient/dev/": {
"product[0].sku": "BL394D",
"product[0].quantity": 8
}
一切都很好,但我们不确定为什么剩余的 consul 配置部分仍然存在,以及它们的用途:
"consul:config/application/dev/": {},
"consul:config/application/": {},
这很有趣,因为我们需要共享配置,以便多个应用程序可以从 consul 加载通用的、特定于环境的配置,如果可能的话;一些问题来确定这是否是一个可行的解决方案:
问题
- 除了应用程序配置路径之外,SCC 是否还尝试从这些位置读取?
- 默认文件夹
config/application是否可配置,以便应用在启动时从config/mysharedconfig读取? - 是否适合将
/config/application/dev用作共享配置位置,多个应用程序可以在其中加载通用的、特定于环境的配置?
【问题讨论】:
标签: java spring spring-cloud consul spring-cloud-consul