如何使用elasticsearch 5.2.1配置Spring Boot? [英] How to configure Spring Boot with elasticsearch 5.2.1?

查看:87
本文介绍了如何使用elasticsearch 5.2.1配置Spring Boot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的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()

I am trying to connect my Spring Boot application to local elasticsearch 5.2.1 instance. When i use "org.springframework.boot:spring-boot-starter-data-elasticsearch" dependency, i face with "Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]". I think this is due to elasticsearch version is 2.4.4 in starter dependency. So to solve this error, i edit pom.xml properties by adding elasticsearch.version>5.2.1/elasticsearch.version> line. But this time i get "java.lang.NoSuchMethodError: org.elasticsearch.client.transport.TransportClient.builder()"

为克服此问题,我创建了如下自定义配置类:

To overcome this issue, i create custom config class like below:

@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例外( 在此处进行检查),因此我添加了必要的依赖项。

This time i get apache.logging.log4j exceptions (check here) so i add necessary dependencies.

最后,我遇到了以下错误并卡在了那里。有人可以帮我解决这个问题吗?

Finally i get below error and stucked there. Could anyone help me out with this?

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

推荐答案

spring-data-elasticsearch 显示,它目前仅支持2.4.0之前的Elasticsearch。

The github page of spring-data-elasticsearch shows that it currently supports elasticsearch only up to version 2.4.0.

目前您有3个选项:


  • 等待与希望

  • 签出拉出请求

  • 检出dev分支5.0.x-prep

这篇关于如何使用elasticsearch 5.2.1配置Spring Boot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆