Spring Boot整合Spring Data Elasticsearch 踩坑

首先来看官网给的版本要求:


红框这栏指的是:Elasticsearch安装版本(windows安装版本或Linux按照版本)

最新因为项目需要elasticsearch,采用今天搞了好久,项目启动就报如下错误:

org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

找了好久以为是配置问题,最后终于明白原来是版本不统一。

我的项目用的spring boot 1.5.x

所以安装了elasticsearch-2.3.2.zip

解压进入bin目录双击elasticsearch.bat。启动服务。

在浏览器输入http://localhost:9200/,返回json字符串证明启动成功。


###################################################################

在springboot中对elasticsearch配置是默认有支持的。



如配置:

#默认 9300 是 Java 客户端的端口。9200 是支持 Restful HTTP 的接口。
#  集群节点地址列表,用逗号分隔。如果没有指定,就启动一个客户端节点
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.repositories.enabled=true

以前就绪,操作就类似于Spring-Data-JPA,具体见官方文档http://projects.spring.io/spring-data-elasticsearch/




猜你喜欢

转载自blog.csdn.net/niugang0920/article/details/80870205