gpt4 book ai didi

java - Maven 不会在复制依赖期间排除

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:37 28 4
gpt4 key购买 nike

我有一个使用 Netty 4.0.29 的项目,我有另一个引入 netty 3.9.0 的依赖项。我放入了一个排除项,但当我运行复制依赖项时,它仍在 3.9.0 中运行。

    <dependency>
<groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId>
<version>1.9.31</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>

如果我运行 mvn dependency:tree 并设置了这个排除项,我会发现它确实被排除在外了:

[INFO] +- com.ning:async-http-client:jar:1.9.31:compile

但是当我运行 mvn clean dependency:copy-dependencies 时,我看到 jar 3.9.0 与 4.0.29 一起被复制。根据文档和谷歌,当有排除时,这不应该复制。

[INFO] Copying netty-3.9.0.Final.jar to /Users/udonom1/wk/141/coursecopy-api/target/dependency/netty-3.9.0.Final.jar
[INFO] Copying netty-all-4.0.29.Final.jar to /Users/udonom1/wk/141/coursecopy-api/target/dependency/netty-all-4.0.29.Final.jar

我尝试按照下面第一个答案的建议进行排除,但没有成功。

        <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>io.netty:netty:3.9.0.Final</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>

我还按照进一步的建议添加了一个依赖项:

    <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.29.Final</version>
</dependency>

我做错了什么?

最佳答案

对于那些有同样问题的人。我使用 mvn -X 并发现 dependency:tree 省略了另外两个引用 netty 的 jar。我为那些添加了排除项,我很高兴。花了一整天的时间。

关于java - Maven 不会在复制依赖期间排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32771875/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com