【问题标题】:ElasticsearchJestHealthIndicator : Health check failed when using Jest in spring bootElasticsearchJestHealthIndicator:在 Spring Boot 中使用 Jest 时运行状况检查失败
【发布时间】:2018-03-15 12:28:35
【问题描述】:

我在我的 Spring Boot 应用程序中使用 enter link description here 的 Jest。

然后我用示例代码创建了客户端:

JestClientFactory factory = new JestClientFactory();
 factory.setHttpClientConfig(new HttpClientConfig
                        .Builder("http://myhost:9200")
                        .multiThreaded(true)
 
 JestClient client = factory.getObject();

一切都很好。我可以使用这个客户端来做我想要的所有查询。快乐到现在。

那么问题来了,当应用程序启动时,ElasticsearchJestHealthIndicator 类是自动初始化的。但问题是我不知道在哪里设置它需要的配置,所以它使用默认值 http://localhost:9200,这导致我遇到这个问题:

WARN [on(2)-127.0.0.1] s.b.a.h.ElasticsearchJestHealthIndicator : 健康检查失败 io.searchbox.client.config.exception.CouldNotConnectException:无法连接到 http://localhost:9200 在 io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:70) 在 io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:60)

谁能告诉我如何正确配置或关闭它?

【问题讨论】:

    标签: spring-boot elasticsearch elasticsearch-jest


    【解决方案1】:

    在参考文档中的快速搜索显示 Spring Boot 将为您配置 JestClient(您可以在任何需要的地方注入它),并且适用以下配置属性:

    spring.elasticsearch.jest.uris=http://search.example.com:9200
    spring.elasticsearch.jest.read-timeout=10000
    spring.elasticsearch.jest.username=user
    spring.elasticsearch.jest.password=secret
    

    here for more on this

    【讨论】:

    • spring.elasticsearch.jest.uris 解决了这个问题!谢谢你:)
    【解决方案2】:

    Jest 客户端也已被弃用,因为 Elasticsearch 和 Spring Data Elasticsearch 都为 REST 客户端提供官方支持。

    https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-elasticsearch

    【讨论】:

      猜你喜欢
      • 2020-02-19
      • 2021-12-26
      • 2022-01-19
      • 2015-01-12
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 2018-04-04
      • 2016-10-05
      相关资源
      最近更新 更多