Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot, Elasticsearch 6.2.4, Gradle dependency issues

I am converting a legacy application to Spring Boot. This application currently uses Elasticsearch 6.2.4

When creating the following dependencies in my build.gradle file, it includes the wrong version of Elasticsearch, 5.6.11:

dependencies {
    // Spring Boot Starters
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.boot:spring-boot-starter-security'
    compile 'org.springframework.boot:spring-boot-starter-mail'

    // Elasticsearch
    compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.4'
}

Output from ./gradlew dependencies

+--- org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.4
|    +--- org.elasticsearch:elasticsearch:6.2.4 -> 5.6.11

I am assuming this is some magic happening due to the io.spring.dependency-management plugin.

How can I override this behavior and still use my explicit configured version while converting this legacy application to Spring Boot?

Note that I am not using spring-data at the moment, nor do I have plans to move to that anytime soon. My current application manages the ES client and all interactions itself without any Spring abstraction layer.

like image 948
ChrisDekker Avatar asked Dec 18 '22 20:12

ChrisDekker


2 Answers

ext {
    set('elasticsearch.version', '6.2.4')
}

Blogpost about overriding versions

like image 142
Vlad Mamaev Avatar answered Dec 20 '22 09:12

Vlad Mamaev


While searching answer for same I came across following soln:

ext['elasticsearch.version'] = '6.2.4'

Reference Doc section 3.1 Customizing managed versions

These versions are picked BOM file available at https://github.com/spring-projects/spring-boot/blob/v2.1.6.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml

The different release would have a different set of versions in the pom file.

like image 24
sonus21 Avatar answered Dec 20 '22 09:12

sonus21