如何在spring boot + cloud中禁用refreshScope运行状况指示器?

时间:2017-10-16 16:14:52

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

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

Actuator health check response

2 个答案:

答案 0 :(得分:3)

使用:

a_holder = tf.placeholder(np.float32)
b = tf.Variable(a_holder)
sess.run(b.initializer, feed_dict={a_holder: np.arange(100000000)})

答案 1 :(得分:0)

您需要创建一个RefreshScopeHealthIndicator的bean并重写doHealthCheck方法,以免引发异常。代码段是Kotlin,但您会明白的。

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