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.
ext {
set('elasticsearch.version', '6.2.4')
}
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.
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')}")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.