文章目录

1. 现象

Elasticsearch7.15.2 报java.lang.NoClassDefFoundError: org/elasticsearch/client/Cancellable的解决方案_elasticsearch

2. 分析定位

原因:查看依赖项的级联关系,发现​​rest-high-level-client​​​这个​​7.15.2​​​包,的引用了​​6.4.3​​的rest-client。

Elasticsearch7.15.2 报java.lang.NoClassDefFoundError: org/elasticsearch/client/Cancellable的解决方案_版本引用_02

3. 解决方案

直接把​​rest-client包的7.15.2版本​​​的依赖项加进来就好了。
springboot集成es7

<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.15.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.15.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.15.2</version>
</dependency>