Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 查找依赖关系颁发者_Java_Maven_Dependencies - Fatal编程技术网

Java 查找依赖关系颁发者

Java 查找依赖关系颁发者,java,maven,dependencies,Java,Maven,Dependencies,我在web项目中使用以下库: slf4j-log4j12-1.6.4.jar slf4j-api-1.6.0.jar log4j-1.2.16.jar jcl-over-slf4j-1.6.0.jar Bu当我组装war时,一个额外的commons-logging-1.0.4.jar库被复制到WEB-INF/lib。我认为这是因为我的一个库依赖于commons-logging-1.0.4.jar。 我想排除commons-logging-1.0.4.jar(因为jcl-over-slf4j-

我在web项目中使用以下库:

  • slf4j-log4j12-1.6.4.jar
  • slf4j-api-1.6.0.jar
  • log4j-1.2.16.jar
  • jcl-over-slf4j-1.6.0.jar
Bu当我组装war时,一个额外的commons-logging-1.0.4.jar库被复制到WEB-INF/lib。我认为这是因为我的一个库依赖于commons-logging-1.0.4.jar。 我想排除commons-logging-1.0.4.jar(因为jcl-over-slf4j-1.6.0.jar已经在这里了)


...

为此,我需要找到pom中依赖于commons日志记录的库。

您可以使用
mvn dependency:tree
命令找到依赖关系树

从树中,可以排除工件

示例输出:

[INFO] |  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.20.0:test
[INFO] |  |  +- org.seleniumhq.selenium:selenium-api:jar:2.20.0:test
[INFO] |  |  +- net.sourceforge.htmlunit:htmlunit:jar:2.9:test
[INFO] |  |  |  +- xalan:xalan:jar:2.7.1:test
[INFO] |  |  |  |  \- xalan:serializer:jar:2.7.1:test
[INFO] |  |  |  +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] |  |  |  +- commons-lang:commons-lang:jar:2.6:test
[INFO] |  |  |  +- org.apache.httpcomponents:httpmime:jar:4.1.2:test
[INFO] |  |  |  +- commons-codec:commons-codec:jar:1.4:test
[INFO] |  |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:test
[INFO] |  |  |  +- xerces:xercesImpl:jar:2.9.1:test
[INFO] |  |  |  |  \- xml-apis:xml-apis:jar:1.3.04:test
如果依赖关系是可传递的,您可以根据上面的树执行以下操作:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.20</version>
</dependency>
<dependency>
    <groupId>net.sourceforge.htmlunit</groupId>
    <artifactId>htmlunit</artifactId>
    <version>2.9</version>
    <!-- i dont want u -->
    <exclusions>
        <exclusion>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </exclusion>
    </exclusions>
</dependency>

org.seleniumhq.selenium
selenium htmlunit驱动程序
2.20
net.sourceforge.htmlunit
htmlunit
2.9
公地收藏
公地收藏
如果您正在使用WAR覆盖功能,而依赖关系树的另一个答案不起作用,请检查有问题的库是否通过覆盖的WAR文件之一进入。作为覆盖的一部分,Maven正在扩展覆盖的WAR文件的
WEB-INF/lib
文件夹,基本上包括生成的WAR文件中的所有内容


要排除以这种方式出现的一些文件,您可以使用WAR插件的
dependentWarExcludes
功能:

正是我所需要的。非常感谢。
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.20</version>
</dependency>
<dependency>
    <groupId>net.sourceforge.htmlunit</groupId>
    <artifactId>htmlunit</artifactId>
    <version>2.9</version>
    <!-- i dont want u -->
    <exclusions>
        <exclusion>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
        </exclusion>
    </exclusions>
</dependency>