spring - 如何禁用 Spring 启动执行器 Elasticsearch 健康请求?

标签 spring spring-boot actuator

我有一个 Spring Boot 应用程序,它使用本地 Elasticsearch 和 Spring Boot Actuator 2.1.2 仅用于度量目的。现在我需要实现一个默认的健康检查,所以我在我的配置 application.properties 类中打开它,如下所示:

management.endpoints.web.exposure.include=...,health
management.endpoint.health.show-details=never

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

但有一个时刻我不喜欢。我发现每次当我得到像 {"status":"UP"} 这样不详细的答案时,执行器都会在

处进行不必要的 Elasticsearch 调用
ElasticsearchHealthIndicator.doHealthCheck(Health.Builder builder)

我打算摆脱无用的电话。

我能以某种方式只禁用这个调用吗?

最佳答案

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

management.health.elasticsearch.enabled=false

关于spring - 如何禁用 Spring 启动执行器 Elasticsearch 健康请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59359451/

相关文章:

spring - 在 Gradle 构建中,启动 Spring Boot 应用程序,运行测试,然后停止 Spring Boot 应用程序

java.lang.IllegalStateException : Cannot load configuration class: com. javainuse.SpringBootHelloWorldApplication

spring - 在 Spring Boot 执行器中设置 endpoints.health.sensitive=false 时无效

java - Spring Security 阻止公共(public)休息服务

java - Spring boot中的RestController - 404错误而不是JSON对象

java - SpringApplicationBuilder用于组合小型SpringBoot应用程序(模块化Monolith)

java - Spring Data JPA 持久化实体,具有嵌套的复合主键实体,其本身是一个在持久化时分离的嵌套实体

java - 如何在 Spring Boot 测试中覆盖 application-test.yml ?