Maven中相同依赖项的不同版本

Different versions of the same dependency in Maven(Maven中相同依赖项的不同版本)
本文介绍了Maven中相同依赖项的不同版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于 Woodstox 和 XStream 的 maven 项目.不幸的是,XStream 也依赖于 Woodstox,但版本比我需要的稍旧.但与此同时,Woodstox 库的工件名称发生了变化,因此 maven 不会将它们视为同一工件的多个版本.但是包名和类名是一样的,就是运行时有冲突.

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.

现在,我显然可以以某种方式从构建中破解旧的woodstox jar(在我们的例子中是 war 文件),但是解决此类问题的正确方法是什么?

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?

推荐答案

您可以在 xstream 的 dependency 声明中尝试 exclude woodstox 依赖.

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中相同依赖项的不同版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

JPMS/Jigsaw Missing Main Class in Module(JPMS/Jigsaw模块中缺少主类)
Can not run JAVAFX .jar File (many errors occurred)(无法运行JavaFX.jar文件(出现许多错误))
JPMS and fatuber executable JAR - how it works together?(JPMS和FATUBER可执行JAR--它是如何协同工作的?)
Use jdk.internal.net.http(使用jdk.inder.net.http)
javax.annotation classes and Java 11 JDK(Javax.Annotation类和Java 11 JDK)
Are Filer#39;s originating elements useful?(FILLER的原始元素有用吗?)