如何禁用 Spring Boot Actuator 弹性搜索运行状况请求?

dar*_*ico 3 spring spring-boot spring-boot-actuator

我有一个 Spring Boot 应用程序,它使用本地弹性搜索和 Spring Boot Actuator 2.1.2 仅用于指标目的。现在我需要实现默认的运行状况检查,因此我在配置 application.properties 类中将其打开,如下所示:

management.endpoints.web.exposure.include=...,health
management.endpoint.health.show-details=never
Run Code Online (Sandbox Code Playgroud)

它工作正常,我可以使用调用http://localhost/actuator/health 的默认实现来实现健康状态。

但有一个时刻我不喜欢。我发现每次当我得到像{"status":"UP"}执行器这样的非详细答案时,都会在以下地址进行不必要的elasticsearch调用

ElasticsearchHealthIndicator.doHealthCheck(Health.Builder builder)
Run Code Online (Sandbox Code Playgroud)

我打算摆脱无用的电话。

我可以以某种方式仅禁用此呼叫吗?

das*_*sum 14

尝试在 application.properties 文件中使用以下属性

management.health.elasticsearch.enabled=false
Run Code Online (Sandbox Code Playgroud)