不同版本的相同依赖关系在Maven中 [英] Different versions of the same dependency in Maven

查看:281
本文介绍了不同版本的相同依赖关系在Maven中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个取决于Woodstox和XStream的maven项目。不幸的是,XStream还取决于Woodstox,但是一个比我需要的版本要老一些。在此期间,Woodstox库的工件名称已更改,因此,maven不会将它们视为同一工件的多个版本。但是包和类的名称是一样的,这意味着在运行时会有冲突。



现在,我显然可以将旧的woodstox jar从构建中删除(a

解决这个问题的正确方法是什么?方案

您可以在您的依赖关系声明中尝试排除 woodstox依赖关系。

 <依赖关系> 
< groupId> xstream.group< / groupId>
< artifactId> xstream< / artifactId>
< version> a.b.c< / version>
<排除>
< exclude>
< groupId> woodstox.group< / groupId>
< artifactId> woodstox< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>


I have a maven project that depends on both Woodstox and XStream. Unfortunately XStream also depends on Woodstox, but a version slightly older than what I need. In the meantime though, the artifact names of the Woodstox libs changed, so maven won't consider them multiple versions of the same artifact. But the package and class names are the same, which means there is a conflict at runtime.

Now, I could obviously hack the old woodstox jar out of the build (a war file in our case) somehow but what is the proper way of solving this type of problem?

解决方案

You could try excluding woodstox dependency in your dependency declaration for xstream.

  <dependency>
        <groupId>xstream.group</groupId>
        <artifactId>xstream</artifactId>
        <version>a.b.c</version>
        <exclusions>
            <exclusion>
                <groupId>woodstox.group</groupId>
                <artifactId>woodstox</artifactId>
            </exclusion>
        </exclusions>
  </dependency>

这篇关于不同版本的相同依赖关系在Maven中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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