Springboot 整合 elasticsearch 8.x版本冲突
Springboot 整合 elasticsearch 版本冲突
Springboot 整合 elasticsearch
maven依赖应与 elasticsearch 服务端版本一致
java.lang.IllegalStateException: Failed to load ApplicationContext at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79) at java.util.ArrayList.forEach(ArrayList.java:1259) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restHighLevelClient' defined in class path resource [com/knowledge/graph/config/EsClientConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'restHighLevelClient' threw exception; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/action/search/ClosePointInTimeRequest at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)
该问题为Springboot 自带的 es版本 和你引入的版本有冲突
查看pom文件,依次点击
可以看到Springboot Es默认的版本号
修改pom文件 properties 加入es版本号
<properties> <java.version>1.8</java.version> <elasticsearch.version>8.6.2</elasticsearch.version> </properties>
es 依赖修改为
<dependency> <groupId>co.elastic.clients</groupId> <artifactId>elasticsearch-java</artifactId> <version>8.6.2</version> </dependency>