我有这样的配置pom.xml
:
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
但不幸mvn dependency:tree
的是,向我展示了commons-beanutils
具有依赖性:commons-collections 3.x:
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
我不想Common Collection 3
在我的代码中,但可能有人错误地使用了这个库中的一个类(而不是Common Collective 4
首选版本)。
正如您在依赖关系树中看到的 - 我不能排除 Common Collection 3,因为它已被使用(可能发生java.lang.NoClassDefFoundError
)。
问题:
如何保护我的代码库免受 Commons Collection 3 API 的污染?