我正在使用elasticsearch7.5。我打开了以下属性

xpack.security.enabled: true
xpack.security.authc.api_key.enabled: true
我已经生成了用于将我们的springboot连接到elasticsearch的API密钥。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
有人可以建议我,我该如何解决。

最佳答案

从您的配置中删除这些行:

spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
这些使Spring Boot可以配置传输客户端。

关于spring-boot - Spring Boot服务器启动问题 Elasticsearch ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63153145/

10-15 22:17