【发布时间】:2017-12-10 22:00:46
【问题描述】:
我希望严格使用 consul 作为配置源。
我正在使用spring-cloud-consul-config 来获取我的配置。
我正在使用git2consul 将文件加载到领事中并阅读它们。
根据spring cloud documentation,我已将以下内容添加到我的 build.gradle
compile ("org.springframework.cloud:spring-cloud-starter-consul-config")
并在我的 application.properties
中有以下内容spring.application.name=test-service
spring.cloud.consul.config.enabled=true
spring.cloud.consul.enabled=true
spring.cloud.consul.config.format=FILES
我面临的问题是预期的属性没有被加载到 ConfigurationProperties bean 中。在 ConsulPropertySourceLocator::locate(Environment environment) 方法中进一步调试时,我看到 this.properties 对象仍加载有 KEY_VALUE 枚举。
这使我进入ConsulConfigBootstrapConfiguration 类,其中 ConsulConfigProperties bean 正在使用构造函数进行实例化。
这是问题还是我的设置有问题。 如果有人有 git2consul 和 spring cloud config 的工作设置,请您指点我以供参考。
【问题讨论】:
-
你用的是什么版本?
/config中有什么内容? -
spring cloud 版本:1.2.1-RELEASE 我在 consul 中的 /config 文件夹有一个文件夹 test-service,其中包含 application.properties 和 test-service.properties。这些文件也存在于 config 文件夹中。
-
它们应该只在
/config中需要。/env执行器端点说什么?
标签: spring-cloud consul spring-cloud-config