启动springboot项目连接elasticsearch索引库时遇到的一个问题: Error creating bean with name 'elasticsearchClient' define

(启动springboot项目连接elasticsearch索引库时遇到的一个问题: Error creating bean with name ‘elasticsearchClient’ defined in class path resource)

  • 最近搭了一个项目,使用SpringBoot整合了Spring Data JPA; 后续打算用SpringCloud ; 另外项目中引入了搜索引擎(索引库). 以前搞过solr, 这次打算尝试elasticsearch . 中途遇到一个问题,琢磨了半个小时多,才解决问题. 记录一下

报错内容:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘elasticsearchClient’ defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method ‘elasticsearchClient’ threw exception; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.common.settings.Settings B u i l d e r . p u t ( L j a v a / u t i l / D i c t i o n a r y ; ) L o r g / e l a s t i c s e a r c h / c o m m o n / s e t t i n g s / S e t t i n g s Builder.put(Ljava/util/Dictionary;)Lorg/elasticsearch/common/settings/Settings Builder.put(Ljava/util/Dictionary;)Lorg/elasticsearch/common/settings/SettingsBuilder;在这里插入图片描述

pom.xml:在这里插入图片描述

  • 为难我半小时多, 版本问题. 把pom.xml中的 < version>3.0.6.RELEASE</ version> 删除,解决问题.

如图: 在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42384113/article/details/106109669