gpt4 book ai didi

elasticsearch - 如何使用 elasticsearch 5.2.1 配置 Spring Boot?

转载 作者:行者123 更新时间:2023-11-29 02:47:13 28 4
gpt4 key购买 nike

我正在尝试将我的 Spring Boot 应用程序连接到本地 elasticsearch 5.2.1 实例。当我使用“org.springframework.boot:spring-boot-starter-data-elasticsearch”依赖项时,我面临“收到来自不受支持版本的消息:[2.0.0] 最小兼容版本是:[5.0.0]”。我认为这是由于 elasticsearch 版本是 2.4.4 启动依赖。因此,为了解决此错误,我通过添加 elasticsearch.version>5.2.1/elasticsearch.version> 行来编辑 pom.xml 属性。但是这次我得到“java.lang.NoSuchMethodError: org.elasticsearch.client.transport.TransportClient.builder()

为了解决这个问题,我创建了如下自定义配置类:

@Configuration
public class ElasticsearchConfiguration {

@Bean
public Client client() throws UnknownHostException {
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));

return client;
}

@Bean
public ElasticsearchTemplate elasticsearchTemplate() throws UnknownHostException {
return new ElasticsearchTemplate(client());
}
}

这次我遇到了 apache.logging.log4j 异常 ( check here ),所以我添加了必要的依赖项。

最后我遇到错误并卡在那里。谁能帮我解决这个问题?

嵌套异常是 java.lang.NoClassDefFoundError:org/elasticsearch/action/count/CountRequestBuilder

最佳答案

spring-data-elasticsearch的github页面表明它目前仅支持 elasticsearch 到 2.4.0 版本。

现在你有 3 个选择:

  • 等待和希望
  • 检查 pull request
  • 检查开发分支 5.0.x-prep

关于elasticsearch - 如何使用 elasticsearch 5.2.1 配置 Spring Boot?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42495090/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com