2017-07-06 108 views
0

我希望严格使用consul作为配置源。 我正在使用spring-cloud-consul-config来获取我的配置。 我正在使用git2consul将文件加载到consul并阅读它们。 由于每spring cloud documentation我加入以下到我的的build.gradleSpring云配置属性不尊重配置属性

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 enum。

这使我转向ConsulConfigBootstrapConfiguration类,其中ConsulConfigProperties bean正在使用构造函数实例化。

这是问题还是我的设置有问题? 如果有人有git2consul和spring cloud config的工作设置,请您指出我的参考。

+0

你使用的是什么版本?什么在'/ config'中? – spencergibb

+0

spring cloud版本:1.2.1-RELEASE consul中的my/config文件夹有一个文件夹test-service,其中包含application.properties和test-service.properties。这些文件也存在于config文件夹中。 – Tanmay

+0

它们只应在'/ config'中需要。 '/ env'执行器端点说了什么? – spencergibb

回答

0

您在application.properties

spring.application.name=test-service 
spring.cloud.consul.config.enabled=true 
spring.cloud.consul.enabled=true 
spring.cloud.consul.config.format=FILES 

需要有这些值是在bootstrap.properties