Java 马文赢了';在复制依赖项期间不排除
我有一个使用Netty 4.0.29的项目,我还有另一个依赖项使用Netty 3.9.0。我加入了一个排除项,但当我运行复制依赖项时,它仍然在3.9.0中起作用Java 马文赢了';在复制依赖项期间不排除,java,maven,Java,Maven,我有一个使用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</v
<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 clean dependency:copy dependencies时,我看到JAR3.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>
org.apache.maven.plugins
maven依赖插件
2.1
复制依赖项
过程源
复制依赖项
${project.build.directory}/lib
假的
假的
真的
io.netty:netty:3.9.0.Final
我还添加了一个依赖项,进一步建议:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.29.Final</version>
</dependency>
伊奥·内蒂
讨厌的
4.0.29.1最终版本
我做错了什么?如果您编写的不是库,那么您有一种简单的方法来控制项目中任何依赖项的版本-根pom文件中的块,例如:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>4.0.29.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludeArtifactIds>io.netty:netty:3.9.0.Final</excludeArtifactIds>
</configuration>
</plugin>
</plugins>
</build>
或者只需在maven调用中使用
-dexcludiartifactids
参数就可以解决同样的问题。我使用了mvn-X,发现dependency:tree忽略了另外两个引用netty的JAR。我添加了这些排除,我很乐意去。为此花了一整天的时间。您可以使用dependencyManagement覆盖所有依赖关系树的某个依赖关系的版本。您能分享您的答案吗?如何排除多个工件将工件与“,”分离,这很有效!非常感谢。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<configuration>
<excludeArtifactIds>io.netty:netty:3.9.0.Final</excludeArtifactIds>
</configuration>
</plugin>
</plugins>
</build>