繁体   English   中英

Spring Boot、Elasticsearch 6.2.4、Gradle 依赖问题

[英]Spring Boot, Elasticsearch 6.2.4, Gradle dependency issues

我正在将旧应用程序转换为 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.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 dependencies输出

+--- 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-data ,也没有计划很快使用它。 我当前的应用程序在没有任何 Spring 抽象层的情况下管理 ES 客户端和所有交互本身。

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

关于覆盖版本的博客文章

在搜索相同的答案时,我遇到了以下解决方案:

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

参考文档 3.1 自定义托管版本

这些版本是从https://github.com/spring-projects/spring-boot/blob/v2.1.6.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml中挑选出来的 BOM 文件

不同的版本在 pom 文件中会有不同的版本集。

添加未来参考。 在 ext 中添加的版本可以使用 property() 进行依赖引用,这样我们就不需要重复版本声明。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM