springboot 集成es是出现这个错误
经过排查发现是因为两者的版本不兼容
springboot版本
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
RestHighLevelClient版本
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifact5.6.0</version>
</dependency>
报错内容:
Description:
An attempt was made to call the method org.elasticsearch.client.RestHighLevelClient.<init>(Lorg/elasticsearch/client/RestClientBuilder;)V but it does not exist. Its class, org.elasticsearch.client.RestHighLevelClient, is available from the following locations:
jar:file:/D:/repository/owner/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.0/elasticsearch-rest-high-level-client-5.6.0.jar!/org/elasticsearch/client/RestHighLevelClient.class
It was loaded from the following location:
file:/D:/repository/owner/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.0/elasticsearch-rest-high-level-client-5.6.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RestHighLevelClient
后面把springboot的版本号改成了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
后面启动就生效了,所以出现以上的提示很大可能是版本兼容问题
觉得文章有帮助的话就赞赏下吧!
微信:
支付宝: