ES 5.0.1, Spring boot 1.5.6

spring boot 1.5.6 整合spring-data-elasticsearch 2.0.4.RELEASE,报错:failed to get node info

  <dependency>
       <groupId>org.springframework.data</groupId>
       <artifactId>spring-data-elasticsearch</artifactId>
       <version>2.0.4.RELEASE</version>
 </dependency>

2017-09-07 09:45:15.299 INFO [elasticsearch[Fin Fang Foom][generic][T#2]] (org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.doSample(TransportClientNodesService.java:420)) - [Fin Fang Foom] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9300}, disconnecting...
org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

2.0.4.RELEASE 不支持 ElasticSearch5.x,改成3.0.0.RC2

<dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.0.0.RC2</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>spring-libs-milestone</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

继续报错:java.lang.NoClassDefFoundError: org/elasticsearch/plugins/NetworkPlugin

Caused by: java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPlugin

按照网上的解决方案,在pom.xml指定ElasticSearch的版本号

<dependency>
     <groupId>org.elasticsearch</groupId>
     <artifactId>elasticsearch</artifactId>
     <version>5.0.1</version>
</dependency>
<dependency>
       <groupId>org.elasticsearch.client</groupId>
       <artifactId>transport</artifactId>
       <version>5.0.1</version>
</dependency>

继续报错:Error creating bean with name 'elasticsearchTemplate' defined in class path resource

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/search/suggest/SuggestBuilder$SuggestionBuilder

找到一个貌似比较靠谱的答案,spring boot 1.x不支持elasticsearch5.x

As I can see in the logs you are trying to use Spring Boot 1.X with the 3.X spring-data-elasticsearch (SDE).
I think that it won’t work that way. SDE 3.X has dependency to spring-data-commons 2.X which as I know will be released with the Spring 5.X.
So in this case you have to use Spring Boot 2.X (2.0.0 M2 or last snapshot) which has dependency to Spring 5.X and uses the SDE 3.X (but to be honest I am not 100% sure is it working right now with latest snapshot of Spring Boot because SDE 3.X is still under development- I’ve tried SDE 3.X but with pure Spring own auto-configuration – not with boot).

spring-data-elasticsearch github代码

https://github.com/spring-projects/spring-data-elasticsearch

参考网址

http://blog.csdn.net/u010882234/article/details/74941954
//www.greatytc.com/p/814c92fe032c
https://stackoverflow.com/questions/41062726/elasticsearch-transportclient-networkplugin-noclassdeffounderror
https://stackoverflow.com/questions/44956426/elasticsearch-5-x-repository-java-spring-boot

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容