Maven 不会在复制依赖期间排除 [英] Maven won't exclude during copy-dependencies

查看:53
本文介绍了Maven 不会在复制依赖期间排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Netty 4.0.29 的项目,并且我有另一个依赖 netty 3.9.0.我加入了一个排除项,但当我运行复制依赖项时,它仍然在 3.9.0 中徘徊.

I have a project that uses Netty 4.0.29 and I have another dependency that pulls in netty 3.9.0. I put in an exclusion but it is still roping in 3.9.0 when I run copy-dependencies.

    <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 并设置此排除,我会看到它确实被排除了:

If I run mvn dependency:tree with this exclusion in place, I see that it is indeed excluded:

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

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

But when I run mvn clean dependency:copy-dependencies I see the jar 3.9.0 being copied along with the 4.0.29. According to the documentation and Google, this should not copy when there is an exclusion.

[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

我尝试按照下面第一个答案的建议进行排除,但没有奏效.

I tried excluding as suggested by the first answer below and that did not work.

        <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>

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

I also added a dependency as further suggested:

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

我做错了什么?

推荐答案

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

For those who are having the same issue. I used mvn -X and discovered that dependency:tree is omitting two other jars that are referencing netty. I added exclusions for those and I'm good to go. Spent a whole day on this.

这篇关于Maven 不会在复制依赖期间排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆