NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{T1T83HHTRaSZ6nkUAPt93w}{192.168.1.100}{192.168.1.100:9300}]]
spring-data-elasticsearch和elasticsearch的版本要匹配
首先進入依賴視圖Diagrams -> show dependencies,按Ctrl+F搜索spring-data-elasticsearch
我的版本是3.2.5.RELEASE,找到對應elasticsearch版本為6.5.0,而我原來的版本為5.6.12
於是乎下載對應版本的elasticsearch鏡像,並運行
docker pull elasticsearch:6.5.0
docker run --name elasticsearch -d -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -e "discovery.type=single-node" elastics
earch:6.5.0
運行成功后,在網頁上輸入虛擬機IP和端口號9200
http://x.x.x.x:9200
跳出如下界面表示運行成功
在application.properties中添加如下配置
spring.elasticsearch.jest.uris=http://x.x.x.x:9200
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=x.x.x.x:9300