在我的项目中, child 库与兄弟库相同,因此我几乎没有依赖关系。我如何移走 child ?例如

compile - Dependencies for source set 'main'.
\--- org.springframework.security:spring-security-config:3.1.3.RELEASE
     +--- org.springframework.security:spring-security-core:3.1.3.RELEASE
     |    \--- aopalliance:aopalliance:1.0
     \--- aopalliance:aopalliance:1.0


因此,如何删除/排除树中作为“org.springframework.security:spring-security-core:3.1.3.RELEASE”子元素的“--- aopalliance:aopalliance:1.0”

最佳答案

一旦知道了所需的依赖关系(大概使用gradle dependencies),就可以通过将transitive设置为false来管理自己的依赖项:

apply plugin: 'java'

repositories {
    jcenter()
}

dependencies {
    compile 'org.springframework.security:spring-security-config:3.1.3.RELEASE'
    compile 'org.springframework:spring-core:3.0.7.RELEASE'
    compile 'aopalliance:aopalliance:1.0'
}

configurations.compile.transitive = false

例如:
$ gradle dependencies
compile
+--- org.springframework.security:spring-security-config:3.1.3.RELEASE
+--- org.springframework:spring-core:3.0.7.RELEASE
\--- aopalliance:aopalliance:1.0

10-07 16:27