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


基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01