【问题标题】:How can I disable the refreshScope health indicator in spring boot + cloud?如何在 spring boot + cloud 中禁用 refreshScope 健康指示器?
【发布时间】:2018-03-28 05:36:08
【问题描述】:

我已使用 health.config.enabled=false 禁用了配置服务器运行状况指示器,但这并没有禁用 refreshScope 运行状况指示器。

【问题讨论】:

    标签: spring spring-boot spring-cloud spring-boot-actuator


    【解决方案1】:

    用途:

    management.health.refresh.enabled=false
    

    【讨论】:

    • 谢谢,我尝试了 refreshScope 的所有排列,但它只是“刷新”。
    【解决方案2】:

    您需要创建一个RefreshScopeHealthIndicator 的bean 并覆盖doHealthCheck 方法以不抛出异常。代码 sn-p 是 Kotlin,但你会明白的。

    @Component
    class CustomHealthIndicator(
        private val scope: ObjectProvider<RefreshScope>,
        private val rebinder: ConfigurationPropertiesRebinder
    ): RefreshScopeHealthIndicator(scope, rebinder) {
        override fun doHealthCheck(builder: Health.Builder) {
               builder.up()
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-09
      • 2015-07-04
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      相关资源
      最近更新 更多