首页 > 解决方案 > maven 仍然列出排除的依赖项

问题描述

我有一个具有这些依赖项的 Maven项目:

 <dependencies>
      <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1200-jdbc41</version>
        <exclusions>
          <exclusion>
            <groupId>org.slf4</groupId>
            <artifactId>slf4j-simple</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
  </dependencies>

如果我运行mvn tree它仍然显示排除的工件:

$ mvn dependency:tree
...
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ testArtifact ---
[INFO] testGroup:testArtifact:jar:1.0-SNAPSHOT
[INFO] \- org.postgresql:postgresql:jar:9.4-1200-jdbc41:compile
[INFO]    +- com.github.dblock.waffle:waffle-jna:jar:1.7:runtime
[INFO]    |  +- net.java.dev.jna:jna:jar:4.1.0:runtime
[INFO]    |  +- net.java.dev.jna:jna-platform:jar:4.1.0:runtime
[INFO]    |  +- org.slf4j:slf4j-api:jar:1.7.7:runtime
[INFO]    |  \- com.google.guava:guava:jar:18.0:runtime
[INFO]    \- org.slf4j:slf4j-simple:jar:1.7.7:runtime   ** <--- BAD ONE

如果我运行依赖项:复制依赖项或阴影 jar 插件之类的东西,它们都会拉入不需要的 jar。

我错过了什么吗?

使用 Maven 3.6.0

标签: javamavendependency-management

解决方案


groupId 不正确。应该是 org.slf4j 而不是 org.slf4(缺少 j)。


推荐阅读