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

  
       org.springframework.data
       spring-data-elasticsearch
       2.0.4.RELEASE
 

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


    
        org.springframework.data
        spring-data-elasticsearch
        3.0.0.RC2
    


    
        spring-libs-milestone
        Spring Milestones
        https://repo.spring.io/libs-milestone
        
            false
        
    

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

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

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


     org.elasticsearch
     elasticsearch
     5.0.1


       org.elasticsearch.client
       transport
       5.0.1

继续报错: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
http://www.jianshu.com/p/814c92fe032c
https://stackoverflow.com/questions/41062726/elasticsearch-transportclient-networkplugin-noclassdeffounderror
https://stackoverflow.com/questions/44956426/elasticsearch-5-x-repository-java-spring-boot

你可能感兴趣的:(ES 5.0.1, Spring boot 1.5.6)