ES 5.0.1, Spring boot 1.5.6

spring boot 1.5.6 整合spring-data-elasticsearch 2.0.4.RELEASE,報(bào)錯(cuò):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>

繼續(xù)報(bào)錯(cuò):java.lang.NoClassDefFoundError: org/elasticsearch/plugins/NetworkPlugin

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

按照網(wǎng)上的解決方案,在pom.xml指定ElasticSearch的版本號(hào)

<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>

繼續(xù)報(bào)錯(cuò):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

找到一個(gè)貌似比較靠譜的答案,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

參考網(wǎng)址

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,506評(píng)論 19 139
  • Spring Boot 參考指南 介紹 轉(zhuǎn)載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 47,253評(píng)論 6 342
  • =========================================================...
    lavor閱讀 3,639評(píng)論 0 5
  • springboot配置選項(xiàng)(一) =======================================...
    JanloongDo_0閱讀 4,907評(píng)論 0 3
  • 第二天一早,我們終于把你送到了腫瘤醫(yī)院。 你清醒的時(shí)候,一直拒絕去醫(yī)院,你怕那個(gè)地方。兩年半前,父親就是因?yàn)槿メt(yī)院...
    阿薩哥閱讀 260評(píng)論 0 0

友情鏈接更多精彩內(nèi)容