使用了Maven排除,但仍在加载依赖项

时间:2019-04-12 18:51:46

标签: java maven

我想防止com.google.common.collect.ImmutableList加载Gephi-toolkit。我知道Gephi-toolkit正在使用-verbose选项加载它,并输出以下内容:

 [Loaded com.google.common.collect.ImmutableList from file:/home/noor/.m2/repository/org/gephi/gephi-toolkit/0.8.2/gephi-toolkit-0.8.2.jar]

我知道com.google.common.collect.ImmutableList是在Guava工件中定义的。我将以下排除项添加到Gephi-toolkit中,但仍在加载它,因为我仍然得到以下行:

   [Loaded com.google.common.collect.ImmutableList from file:/home/noor/.m2/repository/org/gephi/gephi-toolkit/0.8.2/gephi-toolkit-0.8.2.jar]

我在maven中添加了排除项,如下所示:

    <dependency>
          <groupId>org.gephi</groupId>
          <artifactId>gephi-toolkit</artifactId>
          <version>0.8.2</version>
          <exclusions>
            <exclusion>
              <groupId>com.google</groupId>
              <artifactId>guava</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
<dependency>
      <groupId>net.sourceforge.owlapi</groupId>
      <artifactId>owlapi-distribution</artifactId>
      <version>4.1.3</version>
      <exclusions>
        <exclusion>
          <groupId>com.google</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

如何防止这种情况?

mvn dependency:tree -Dverbose的输出:

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------< aml:aml >-------------------------------
[INFO] Building AgreementMakerLight 2.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ aml ---
[INFO] aml:aml:jar:2.1-SNAPSHOT
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] +- org.gephi:gephi-toolkit:jar:0.8.2:compile
[INFO] +- com.github.jaytaylor:jaws:jar:1.3.1:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- com.github.firemaples:microsoft-translator-java-api:jar:0.8.7:compile
[INFO] |  +- com.googlecode.json-simple:json-simple:jar:1.1:compile
[INFO] |  \- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] +- net.sourceforge.owlapi:owlapi-distribution:jar:4.1.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.5.1:compile
[INFO] |  |  +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile - omitted for conflict with 2.5.1)
[INFO] |  |  \- (com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile - omitted for duplicate)
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.1:compile
[INFO] |  +- org.tukaani:xz:jar:1.5:compile
[INFO] |  +- org.openrdf.sesame:sesame-model:jar:2.7.12:compile
[INFO] |  |  \- org.openrdf.sesame:sesame-util:jar:2.7.12:compile
[INFO] |  |     \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.7.10)
[INFO] |  +- org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-binary:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-n3:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-nquads:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-rdfjson:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (com.fasterxml.jackson.core:jackson-core:jar:2.2.1:compile - omitted for conflict with 2.5.1)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-trix:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (commons-io:commons-io:jar:2.4:compile - omitted for duplicate)
[INFO] |  +- org.openrdf.sesame:sesame-rio-trig:jar:2.7.12:compile
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  +- (org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:runtime - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-util:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- com.github.jsonld-java:jsonld-java-sesame:jar:0.5.0:compile
[INFO] |  |  +- com.github.jsonld-java:jsonld-java:jar:0.5.0:compile
[INFO] |  |  |  +- (com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile - omitted for conflict with 2.5.1)
[INFO] |  |  |  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile - omitted for conflict with 2.5.1)
[INFO] |  |  |  +- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.6.1)
[INFO] |  |  |  +- org.apache.httpcomponents:httpclient-cache:jar:4.2.5:compile
[INFO] |  |  |  |  \- (org.apache.httpcomponents:httpclient:jar:4.2.5:compile - omitted for duplicate)
[INFO] |  |  |  +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
[INFO] |  |  |  |  +- org.apache.httpcomponents:httpcore:jar:4.2.4:compile
[INFO] |  |  |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] |  |  |     \- (org.slf4j:slf4j-api:jar:1.7.7:runtime - omitted for conflict with 1.6.1)
[INFO] |  |  +- (org.openrdf.sesame:sesame-model:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile - omitted for duplicate)
[INFO] |  +- org.semarglproject:semargl-sesame:jar:0.6.1:compile
[INFO] |  |  +- org.semarglproject:semargl-core:jar:0.6.1:compile
[INFO] |  |  +- org.semarglproject:semargl-rdfa:jar:0.6.1:compile
[INFO] |  |  |  +- (org.semarglproject:semargl-core:jar:0.6.1:compile - omitted for duplicate)
[INFO] |  |  |  \- org.semarglproject:semargl-rdf:jar:0.6.1:compile
[INFO] |  |  |     \- (org.semarglproject:semargl-core:jar:0.6.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.openrdf.sesame:sesame-rio-api:jar:2.7.5:compile - omitted for conflict with 2.7.12)
[INFO] |  +- net.sf.trove4j:trove4j:jar:3.0.3:compile
[INFO] |  +- com.google.guava:guava:jar:18.0:compile
[INFO] |  +- com.google.inject:guice:jar:4.0:compile
[INFO] |  |  +- javax.inject:javax.inject:jar:1:compile
[INFO] |  |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  \- (com.google.guava:guava:jar:16.0.1:compile - omitted for conflict with 18.0)
[INFO] |  +- com.google.inject.extensions:guice-assistedinject:jar:4.0:compile
[INFO] |  |  \- (com.google.inject:guice:jar:4.0:compile - omitted for duplicate)
[INFO] |  +- com.google.inject.extensions:guice-multibindings:jar:4.0:compile
[INFO] |  |  \- (com.google.inject:guice:jar:4.0:compile - omitted for duplicate)
[INFO] |  +- com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.10:compile
[INFO] |  \- commons-io:commons-io:jar:2.4:compile
[INFO] +- uk.ac.shef.wit:simmetrics:jar:1.6.2:compile
[INFO] \- org.swinglabs.swingx:swingx-all:jar:1.6.4:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.661 s
[INFO] Finished at: 2019-04-12T21:13:16+02:00
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:2)

根据mvn dependency:tree -Dverbose的输出,库guava作为net.sourceforge.owlapi:owlapi-distribution:jar:4.1.3依赖项的一部分被加载。

请执行以下排除操作:

<dependency>
    <groupId>net.sourceforge.owlapi</groupId>
    <artifactId>owlapi-osgidistribution</artifactId>
    <version>4.1.3</version>
    <exclusions>
        <exclusion>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </exclusion>
    </exclusions>
</dependency>

以防万一,请尝试重新导入所有依赖项或清空.m2文件夹。