【发布时间】:2020-07-30 13:37:11
【问题描述】:
我正在使用elasticsearch7.5。我开启了以下属性
xpack.security.enabled: true
xpack.security.authc.api_key.enabled: true
我已生成 API 密钥以将我们的 springboot 连接到 elasticsearch。我正在使用
spring-boot-starter-data-elasticsearch
我所有的请求都来自“RestHighClient”并且能够触发请求。唯一的问题是在服务器启动期间,它们是一些无法连接到 Elasticsearch 的错误。
org.elasticsearch.transport.RemoteTransportException: [ADMIN-PC][127.0.0.1:9300][cluster:monitor/nodes/liveness]
Caused by: org.elasticsearch.ElasticsearchSecurityException: missing authentication credentials for action [cluster:monitor/nodes/liveness]
在 pom.xml 中
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.8.3</version>
</dependency>
在应用程序属性中:
spring.elasticsearch.server=localhost:9200
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
spring.data.elasticsearch.repositories.enabled=true
有人可以建议我,我该如何解决它。
【问题讨论】:
-
如何配置与 Elasticsearch 的连接?尽管您使用的是其余客户端,但 Spring-Boot 似乎自动配置了一个连接到 localhost:9300 的 TransportClient。
-
是的..我怎么能阻止这个
-
那么,您如何配置您的应用程序?请发布相关属性。
-
用 pom.xml 和属性更新了描述
标签: spring-boot elasticsearch spring-data-elasticsearch