我試圖使用彈性數據庫附帶的彈簧數據彈性。我的elasticsearch服務器版本是5.2.2;並且xpack已啓用。也就是說,它需要用戶名和密碼才能連接到它。通過spring-data-elasticsearch連接到xpack啓用elasticsearch 5.x
的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
</dependencies>
application.yml
spring:
data:
elasticsearch:
cluster-nodes: localhost:9200
properties:
shield:
user: "elastic:changeme"
我找不到如何設置用戶名和密碼正確。我總是得到以下錯誤:
2017-03-16 16:54:53.222 INFO 4005 --- [ main] org.elasticsearch.client.transport : [Fixx] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9200}, disconnecting...
org.elasticsearch.transport.ReceiveTimeoutTransportException: [][127.0.0.1:9200][cluster:monitor/nodes/liveness] request_id [0] timed out after [5006ms]
at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:698) ~[elasticsearch-2.4.4.jar:2.4.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_111]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_111]
是的,你說得對。我錯過了版本衝突。然而,在這個時候,spring-data-elasticsaerch並不幸地支持elasticsearch 5.x。因此,只將elasticsearch客戶端升級到5.x並不能解決問題。我將放棄spring-data-elasticsearch並改爲使用裸機。 – Muatik