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