Correct the classpath of your application so that it contains a single, compatible version of xxxxxx

本文详细解析了在SpringBoot项目中集成Elasticsearch时遇到的版本不兼容问题,特别是当使用特定版本的SpringBoot Starter Web和RestHighLevelClient时出现的错误。通过调整SpringBoot的版本,成功解决了这一问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

后面启动就生效了,所以出现以上的提示很大可能是版本兼容问题

觉得文章有帮助的话就赞赏下吧!

 

微信:

支付宝:

 

 

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坑里水库

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值