Spring Cloud Config Client禁用数据库运行状况检查

时间:2020-03-27 15:58:04

标签: spring-boot spring-cloud health-check

我正在运行一个spring.boot应用程序,该应用程序从spring-cloud配置服务器获取配置。该应用程序非常简单,其余的api可以访问Oracle数据库。在应用程序上下文中,有一个用Hihari池包装的Oracle数据源。

运行/ actuator / health时,不会触发数据库运行状况检查。输出:

{
  status: "UP",
  components: {
    clientConfigServer: {
      status: "UP",
      details: {
        propertySources: [
          "configClient",
          "/var/git-repo/xxx/xxx-localhost.yml",
          "/var/git-repo/application-localhost.properties",
          "/var/git-repo/xxx/xxx.yml",
          "/var/git-repo/application.properties"
        ]
      }
    },
    discoveryComposite: {
      description: "Discovery Client not initialized",
      status: "UNKNOWN",
      components: {
        discoveryClient: {
          description: "Discovery Client not initialized",
          status: "UNKNOWN"
        }
      }
    },
    diskSpace: {
      status: "UP",
      details: {
        total: 1587526397952,
        free: 1272794873856,
        threshold: 10485760
      }
    },
    ping: {
      status: "UP"
    },
    refreshScope: {
      status: "UP"
    }
  }
}

但是,如果我打开配置服务器,而是通过以下方式使用本地配置:spring.cloud.config.enabled = false,则输出为:

{
  status: "UP",
  components: {
    db: {
      status: "UP",
      details: {
        database: "Oracle",
        result: "Hello",
        validationQuery: "SELECT 'Hello' from DUAL"
      }
    },
    discoveryComposite: {
      description: "Discovery Client not initialized",
      status: "UNKNOWN",
      components: {
        discoveryClient: {
          description: "Discovery Client not initialized",
          status: "UNKNOWN"
        }
      }
    },
    diskSpace: {
      status: "UP",
      details: {
        total: 1587526397952,
        free: 1272794869760,
        threshold: 10485760
      }
    },
    ping: {
      status: "UP"
    },
    refreshScope: {
      status: "UP"
    }
  }
}

我敢肯定对此有一个解释,但我似乎找不到它,因此将不胜感激。

1 个答案:

答案 0 :(得分:0)

结果证明spencergibb是绝对正确的。在常见的application.properties中,有人在大约五年前添加了management.health.db.enabled = false。谜团解决了。