最近在使用springboot整合elasticsearch,发现配置文件都是一致,启动也没有任何问题,执行查询就会报错,错误如下
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1},
网上查询资料很多都是说es配置和项目的配置不一致,下面是我配置的配置文件
es中 elasticsearch.yml
# Use a descriptive name for your cluster:
cluster.name: myEs
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.230.80
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
项目中 application.yml
spring:
data:
elasticsearch:
# es 连接名称
cluster-name: myEs
# es 连接地址
cluster-nodes: 192.168.230.80:9300
server:
port: 8080
发现启动项目都没有报错,执行查询报错。
解决办法:
该问题可能是因为springboot的版本不同对应支持的elasticsearc不一致造成的,我的pom中
而我本地安装的es是5.5.1版本,由此可知是版本不一致造成的,选择安装6.X.X的elasticsearch版本,或者降低springboot版本,我选择降低springboot版本,修改
再次启动查询就正常了!以上个人总结,如有错误,欢迎指正!