Currently elasticsearch is autoconfigured by mentioning this property in application.yml file
spring:
elasticsearch:
rest:
uris:
But my requirement is to not keep this property in this file while still have health check enabled. How to manually configure that?
I was manually creating RestHighLevelClient in configuration class so in same class I just added below method to create low level Rest Client which is internally used for autoconfiguring health check and this solved my issue.
// This low level rest client is used for health check
@Bean
public RestClient Healthclient() {
return getClient().getLowLevelClient();
}
public RestHighLevelClient getClient() {
return client;
}
For more info checkout this - https://github.com/spring-projects/spring-boot/issues/17464