首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle -无法跟踪传递依赖

Gradle -无法跟踪传递依赖
EN

Stack Overflow用户
提问于 2016-04-28 03:09:42
回答 1查看 1K关注 0票数 3

我有两个模块:公共模块和域模块。域是公共的依赖项。在域上,我试图添加的最新版本,但它一直恢复到旧版本。我域的build.gradle文件如下所示:

域build.gradle

代码语言:javascript
复制
apply plugin: 'spring-boot'

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-redis")
compile("org.springframework.data:spring-data-elasticsearch:2.0.1.RELEASE")
compile 'org.slf4j:slf4j-api'
compile 'com.google.guava:guava:19.0'

compile 'com.google.code.gson:gson:2.4'
testCompile "org.mockito:mockito-core:1.+"
}

这里的elasticsearch版本是2.0.1.RELASE,但是,如果我共同运行dependencyInsight,它将检索1.3.4 instead:

代码语言:javascript
复制
gradle dependencyInsight --dependency elasticsearch --configuration compile
:common:dependencyInsight

Download https://repo1.maven.org/maven2/org/springframework/data/spring-data-elasticsearch/1.3.4.RELEASE/spring-data-elasticsearch-1.3.4.RELEASE.pom

org.elasticsearch:elasticsearch:1.5.2 (selected by rule) 
\--- org.springframework.data:spring-data-elasticsearch:1.3.4.RELEASE
 \--- project :domain
      \--- compile

org.springframework.data:spring-data-elasticsearch:1.3.4.RELEASE (selected by rule)

org.springframework.data:spring-data-elasticsearch:2.0.1.RELEASE -> 1.3.4.RELEASE
\--- project :domain
 \--- compile

公共build.gradle

代码语言:javascript
复制
apply plugin: 'spring-boot'


buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
}
}    

dependencies {
compile project(':domain')
compile 'com.google.code.gson:gson:2.4'
compile 'org.owasp.encoder:encoder:1.2'
compile 'com.ning:async-http-client:1.9.31'
compile 'org.slf4j:slf4j-api'
compile 'org.springframework.security:spring-security-core'
compile 'org.springframework.security:spring-security-acl:4.0.3.RELEASE'
compile 'javax.mail:javax.mail-api:1.5.4'
compile 'com.sun.mail:javax.mail:1.5.4'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile "org.mockito:mockito-core:1.+"
}

是否有理由让1.3.4版reason取代2.0.1?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-28 19:12:10

您正在将Spring的Gradle插件应用到您的普通项目中。这意味着它的依赖关系管理将控制项目依赖项的版本。要获得所需的版本,可以通过添加以下内容来覆盖Boot的依赖关系管理:

代码语言:javascript
复制
dependencyManagement {
    dependencies {
        dependency 'org.springframework.data:spring-data-elasticsearch:2.0.1.RELEASE'
    }
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36904563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档