有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Maven可传递依赖公共集合版本3 vs 4

我在^{中有这样的配置:

    <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

正如您在dependency tree中看到的,我不能排除Common Collection 3,因为它已被使用(可能发生java.lang.NoClassDefFoundError

问题:

如何保护我的代码库免受Commons Collection 3 API的污染


共 (1) 个答案