ConfigServerHealthIndicator未检查正确的配置文件

时间:2018-05-14 15:02:19

标签: spring-cloud

我们正在研究为什么我们的spring配置服务器总是返回健康状态“DOWN”,即使它实际上正在工作。

在spring框架中调试后,我们发现ConfigServerHealthIndicator类始终在读取“默认”配置文件。

这是我们的问题,因为默认配置文件在我们的生产环境中不起作用,我们希望配置服务器读取相应的存储库。

根据我们在代码中看到的内容,setRepositories根本不是调用。

我们错过了使ConfigServerHealthIndicator读取相应存储库的任何配置吗? 覆盖豆可能吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

找到答案。 我错过了注释'@ConfigurationProperties(“spring.cloud.config.server.health”)'',这意味着这个类是配置的映射器。

如果您遇到的问题与我相同,请查看https://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.3.1.RELEASE/,“健康指标”部分。

您需要设置一个存储库配置,如:

spring:
  cloud:
    config:
      server:
        health:
          repositories:
            myservice:
              label: mylabel
            myservice-dev:
              name: myservice
              profiles: development