Spring Boot,Elasticsearch 6.2.4,渐变依赖性问题
我正在将一个遗留应用程序转换为Spring Boot。此应用程序当前使用Elasticsearch 6.2.4 在我的Spring Boot,Elasticsearch 6.2.4,渐变依赖性问题,spring,spring-boot,elasticsearch,Spring,Spring Boot,elasticsearch,我正在将一个遗留应用程序转换为Spring Boot。此应用程序当前使用Elasticsearch 6.2.4 在我的build.gradle文件中创建以下依赖项时,它包含错误版本的Elasticsearch 5.6.11: dependencies { // Spring Boot Starters compile 'org.springframework.boot:spring-boot-starter-web' compile 'org.springframewor
build.gradle
文件中创建以下依赖项时,它包含错误版本的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'
}
来自/gradlew依赖项的输出
+--- org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.4
| +--- org.elasticsearch:elasticsearch:6.2.4 -> 5.6.11
我假设这是由于io.spring.dependency management
插件而产生的奇迹
如何在将此遗留应用程序转换为Spring Boot时覆盖此行为并仍然使用显式配置的版本
请注意,我目前没有使用spring数据
,也没有计划在短期内使用该数据。我当前的应用程序管理ES客户端和所有交互本身,无需任何Spring抽象层。
ext {
set('elasticsearch.version', '6.2.4')
}
在搜索相同的答案时,我遇到了以下解决方案:
ext['elasticsearch.version'] = '6.2.4'
这些版本是拾取的BOM表文件,可在
不同的版本在pom文件中会有不同的版本集。添加将来的引用。可以使用property()在依赖项中引用ext中添加的版本,这样就不需要重复版本声明
compile ("org.elasticsearch.client:elasticsearch-rest-high-level-client:${property('elasticsearch.version')}")
谢谢你,弗拉德!这似乎奏效了。虽然我找不到你的解决方案,但是在你链接的博客帖子中我找到了。我很想了解它是如何工作的,以及这种方法可能存在的任何潜在问题。下面是另一个链接,它解释了在使用依赖关系管理插件时覆盖版本的方法: