启动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.SettingsBuilder.put(Ljava/util/Dictionary;)Lorg/elasticsearch/common/settings/SettingsBuilder.put(Ljava/util/Dictionary;)Lorg/elasticsearch/common/settings/SettingsBuilder;启动springboot项目连接elasticsearch索引库时遇到的一个问题: Error creating bean with name 'elasticsearchClient' define

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

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

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