• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

解决SpringBoot整合ElasticSearch遇到的连接问题

springboot 搞代码 4年前 (2022-01-05) 71次浏览 已收录 0个评论
文章目录[隐藏]

这篇文章主要介绍了解决SpringBoot整合ElasticSearch遇到的连接问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

SpringBoot整合ElasticSearch的连接问题

failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{4J2eCGFXSZmM3xH72WIF5A}{192.168.252.200}{192.168.252.200:9300}]

我再使用SpringBoot2.2.0,ES版本5.5时,Spring-boot-data-elasticsearch开发整合启动出现上面的错误。

一开始以为是es节点名称或者ip端口写错了,但是看了半天也没有问题,浏览器也可以直接访问es集群。

之后去Spring文档中查看,发现SpringBoot对Spring-boot-data-elasticsearch的版本进行了讲解

发现SpringBoot2.1.x使用的spring data es是3.1.x适配es6.x

而SpringBoot2.0.x使用3.0.x适配ES5.x

SpringBoot1.5.x就只能使用ES2.4.x的版本了

然后我把SpringBoot版本改为2.0.0之后成功启动没报错,并成功访问

可以看到,正如文档所说,SpringBoot2.0.0使用的Spring-data-elasticsearch是3.0.5的版本,即对于es5.x的版本

正确访问接口

springboot整合Elasticsear来源gao@daima#com搞(%代@#码网ch6.3.2踩坑

首先确保Elasticsearch6.3.2安装成功

1.出现NoNodeAvailableException[None of the configured nodes are available

解决:elasticsearch6.3.2的配置文件修改如下:

 network.host: 192.168.3.222  #改成自己局域网ip transport.tcp.port: 9300     #springboot连接使用的端口 transport.tcp.compress: true http.port: 9100

2.not part of the cluster,节点不属于集群问题

本人使用的是单节点

在浏览器输入ip+端口

上图中框出来的就是在springboot配置文件中cluster-name的值

3.NoSuchFieldError: LUCENE_6_0_0

本人的springboot版本是2.1.7RELEASE,在依赖中加上

  org.apache.lucenelucene-core7.4.0

4.Elasticsearch health check failed

解决:增加spring.elasticsearch.rest 的配置

 spring: data: elasticsearch: cluster-name: docker-cluster cluster-nodes: 192.168.3.68:9300 elasticsearch: rest: uris: [http://192.168.3.68:9100]

配置好 uris 即可~

以上就是解决SpringBoot整合ElasticSearch遇到的连接问题的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:解决SpringBoot整合ElasticSearch遇到的连接问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址