Python 官方文档:入门教程 => 点击学习
SpringBoot整合elasticsearch的连接问题 failed to load elasticsearch nodes : org.elasticsearch.clie
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的版本
正确访问接口
首先确保Elasticsearch6.3.2安装成功
解决:elasticsearch6.3.2的配置文件修改如下:
network.host: 192.168.3.222 #改成自己局域网ip
transport.tcp.port: 9300 #springboot连接使用的端口
transport.tcp.compress: true
Http.port: 9100
本人使用的是单节点
在浏览器输入ip+端口
上图中框出来的就是在springboot配置文件中cluster-name的值
本人的springboot版本是2.1.7RELEASE,在依赖中加上
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>7.4.0</version>
</dependency>
解决:增加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 即可~
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: 解决SpringBoot整合ElasticSearch遇到的连接问题
本文链接: https://www.lsjlt.com/news/132406.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0