Elasticsearch version for Spring Boot 2.1

Viewed 6156

In my Spring Boot(2.0.5) project I was using Elasticsearch(5.6.9). However, due to some bugs in testing environment we are moving to Spring boot(2.1.0). When I run the application the following message comes up:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.execute()Lorg/elasticsearch/action/ActionFuture; but it does not exist. Its class, org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder, is available from the following locations:

    jar:file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar!/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.class

It was loaded from the following location:

    file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder


Process finished with exit code 0

Current pom.xml file

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/>
    </parent>
    <properties>
        <elasticsearch.version>5.6.9</elasticsearch.version>
    </properties>
    <dependencies>

        <!--...others...-->     

        <!--ELASTICSEARCH-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>transport-netty4-client</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
    </dependencies>

Previous pom.xml file which worked fine:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
        <relativePath/> 
    </parent>
    <properties>
        <elasticsearch.version>5.6.9</elasticsearch.version>
    </properties>
    <dependencies>

        <!--...others...-->     

        <!--ELASTICSEARCH-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>transport-netty4-client</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
    </dependencies>

Can someone tell which version of elasticsearch is compatible with Spring Boot 2.1.0? I read through similar questions which were outdated. Compatible versions of Spring boot,elasticsearch and spring data elasticsearch

2 Answers

You can go to Spring Boot project Github repository and check any dependency version:

  • In Spring Boot 2.0.x Elasticsearch version is defined as 5.6.16 (link)
  • In Spring Boot 2.1.x Elasticsearch version is defined as 6.4.3 (link)

Not sure if it's still actual, but the first thing you need to try is to add core Elasticsearch library, because REST client depends on it.

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>6.7.0</version>
</dependency>
Related