目前,elasticsearch是通过在application.yml文件中提及此属性来自动配置的
spring:
elasticsearch:
rest:
uris:但我的要求是,在启用运行状况检查的同时,不要将此属性保留在此文件中。如何手动配置?
发布于 2021-01-04 14:48:46
我是在configuration类中手动创建RestHighLevelClient的,所以在同一个类中,我只是添加了下面的方法来创建低级Rest客户端,该客户端在内部用于自动配置健康检查,这解决了我的问题。
// This low level rest client is used for health check
@Bean
public RestClient Healthclient() {
return getClient().getLowLevelClient();
}
public RestHighLevelClient getClient() {
return client;
}有关更多信息,请查看此处- https://github.com/spring-projects/spring-boot/issues/17464
发布于 2020-12-24 20:31:05
您可以简单地手动调用Elasticsearch cluster health API的REST端点,因为您只调用这个REST端点,您将拥有所有的控制权,比如您想要调用的持续时间、要解析的所有内容以及如何通知/执行状态。
https://stackoverflow.com/questions/65438023
复制相似问题