您好我得到了Maven文件
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<!-- Dependency on log4j will be removed in subsequent versions
see https://issues.apache.org/jira/browse/ZOOKEEPER-850 -->
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- TEST -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<!-- There is no current version of zookeeper-test jar -->
<version>3.4.3</version>
<scope>test</scope>
<classifier>tests</classifier>
<exclusions>
<!-- only needed for log4j -->
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
</exclusions>
</dependency>
我希望在Gradle上做同样的事情
compile(group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.4.5') {
exclude(group: 'org.slf4j', module: 'slf4j-log4j12')
exclude(group: 'log4j', module: 'log4j')
}
testCompile(group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.4.3', classifier: 'tests') {
exclude(module: 'jmxri')
exclude(module: 'jmxtools')
}
但Gradle仍尝试使用最新版本,因此在尝试运行测试时遇到错误。 知道如何在Gradle中完成这项工作吗?
答案 0 :(得分:2)
Gradle基于每个模块执行冲突解决,但分类器仅影响工件,而不影响模块。 (换句话说,zookeeper-tests
没有自己的POM。)一种解决方案是切换到测试类路径的zookeeper-3.4.3
(除zookeeper-3.4.3-tests
之外)。或者,如果您有二进制存储库管理器,则可以更改两个依赖项之一的组或工件ID。