ChrisDekker
ChrisDekker

Reputation: 1773

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.

Upvotes: 5

Views: 2817

Answers (3)

Kumar V
Kumar V

Reputation: 1670

Adding the future reference. The version added in ext can be referenced in dependency using property() so that we don't need to duplicate version declaration.

compile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${property('elasticsearch.version')}")

Upvotes: 0

sonus21
sonus21

Reputation: 5388

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.

Upvotes: 2

Vlad Mamaev
Vlad Mamaev

Reputation: 565

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

Blogpost about overriding versions

Upvotes: 13

Related Questions