Actuator Elasticsearch healthcheck error


1. 相关环境

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
  <version>2.1.4.RELEASE</version>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
  <version>2.1.4.RELEASE</version>
</dependency>

2. 问题

当引入了spring-boot-start-actuator对项目中elasticsearch进行健康检查时报错:java.lang.NoClassDefFoundError: org/elasticsearch/client/Request

 

问题排查:

 

到这个包org.elasticsearch.client中去找,发现确实没有Request类

这个包是在引入spring-boot-starter-data-elasticsearch的时候一起引入进来的

 

试图改变包的版本,发现只有最新版本2.2.0中包含了org.elasticsearch.client.Request类

但是当我们把版本改到2.2.0的时候又会有新的错误,直接报: java.net.ConnectException: Connection refused

elasticsearch连不上了。

改变actuator的版本同样不能解决问题。

3. 解决办法

方法一
spring.data.elasticsearch.cluster-name=docker-cluster-50 spring.data.elasticsearch.cluster-nodes=ip:9300 spring.elasticsearch.rest.uris=["http://ip:9200"]
方法二
management.health.elasticsearch.enabled=false

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM