你好我有这样的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 中完成的吗?