首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Gradle中排除隐藏的依赖的最佳方法是什么?

在Gradle中排除隐藏的依赖的最佳方法是什么?
EN

Stack Overflow用户
提问于 2015-12-08 15:35:28
回答 2查看 1.7K关注 0票数 0

例如,在Gradle项目的依赖项中可以看到这一点:

代码语言:javascript
复制
+--- org.springframework.security:spring-security-core: -> 3.2.7.RELEASE
     +--- aopalliance:aopalliance:1.0
     +--- org.springframework:spring-beans:3.2.13.RELEASE -> 4.1.7.RELEASE (*)
     +--- org.springframework:spring-expression:3.2.13.RELEASE -> 4.1.7.RELEASE (*)
     +--- org.springframework:spring-aop:3.2.13.RELEASE -> 4.1.7.RELEASE (*)
     +--- org.springframework:spring-context:3.2.13.RELEASE -> 4.1.7.RELEASE
     |    +--- org.springframework:spring-aop:4.1.7.RELEASE (*)
     |    +--- org.springframework:spring-beans:4.1.7.RELEASE (*)
     |    +--- org.springframework:spring-core:4.1.7.RELEASE (*)
     |    \--- org.springframework:spring-expression:4.1.7.RELEASE (*)
     \--- org.springframework:spring-core:3.2.13.RELEASE -> 4.1.7.RELEASE (*)

是否可以排除org.springframework:spring-expression而不首先将org.springframework:spring-context排除在org.springframework.security:spring-security-core之外?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-12-08 18:36:54

我建议将它添加到您的Gradle构建中,也许:

代码语言:javascript
复制
dependencies {
  // Explicitly include spring-expression transitive dependency then manage its dependencies
  compile('org.springframework:spring-context:3.2.13.RELEASE') {
    transitive = false
  }
}

还可以强制使用“分级用户指南”中的特定传递依赖项见第52.4.2节。客户模块依赖关系

票数 0
EN

Stack Overflow用户

发布于 2015-12-08 17:09:00

为了从任何配置中排除依赖关系,请使用:

代码语言:javascript
复制
 configurations {
   all {
     exclude group: 'org.springframework', module: 'spring-expression'
   }
 }

如果要强制执行特定版本的依赖关系,可以使用:

代码语言:javascript
复制
 configurations.all {
   resolutionStrategy.eachDependency { DependencyResolveDetails details ->
     if (details.requested.group == 'org.springframework') {
       details.useVersion '3.2.13.RELEASE'
     }
   }
 }

如果在不同版本中多次提取传递依赖项,这可能会有所帮助。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34159871

复制
相关文章

相似问题

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