【问题标题】:Spring cloud config properties not honouring config propertiesSpring Cloud 配置属性不尊重配置属性
【发布时间】: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


【解决方案1】:

您在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

【讨论】:

    猜你喜欢
    • 2016-07-12
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 2019-02-15
    • 2020-06-14
    • 2019-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多