Spring Boot, Elasticsearch 6.2.4, Gradle dependency issues

Viewed 2042

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.

3 Answers

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')}")
Related