由于java.lang.NoClassDefFoundError无法运行代码:com / fasterxml / jackson / annotation / JsonMerge [英] Cannot run code due to java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge

查看:297
本文介绍了由于java.lang.NoClassDefFoundError无法运行代码:com / fasterxml / jackson / annotation / JsonMerge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Intellij Idea 2018社区版中有一些测试代码,它有多个pom文件。当我运行任何testng注释测试时,我收到一条错误,上面写着没有找到测试。看起来问题是由于异常堆栈跟踪的这一部分:

I have some test code in Intellij Idea 2018 community edition, which has multiple pom files. When I run any testng annotated test, I get an error which says "no tests were found". It looks like the problem is due to this part of the exception stack trace:

java.lang.NoClassDefFoundError:com / fasterxml / jackson / annotation / JsonMerge

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge

我搜索了一个解决方案,发现了这个问题 - https ://github.com/FasterXML/jackson-annotations/issues/119 https://stackoverflow.com/a/ 46406070个。看起来这个问题是因为我们在项目中没有相同版本的这些jar。

I googled for a solution and found this - https://github.com/FasterXML/jackson-annotations/issues/119 and this https://stackoverflow.com/a/46406070. It looks like this issue is caused when we don't have the same version of these jars in the project.

1)jackson-core(2.8.8)

1) jackson-core (2.8.8)

2)jackson-databind(2.9.2)

2) jackson-databind (2.9.2)

3)jackson-annotations(2.8.5)

3) jackson-annotations (2.8.5)

正如你所看到的,我对所有的罐子没有相同的版本。我查看了项目中的所有poms,并没有找到任何添加所有这些依赖项的地方。我希望只在那里设置版本号。我应该简单地在父pom文件中添加所有依赖项还是执行其他操作?

As you can see, I don't have the same version for all the jars. I looked at all the poms in my project and did not find any place where all these dependencies are added. I was hoping to simply set the version number there. Should I simply add all dependencies in my parent pom file or do something else ?

如何在不损害项目的情况下解决此问题?如何找出这些罐子的版本不同的原因?

How do I resolve this issue without harming the project ? How do I find out why these jars are not of the same version ?

推荐答案

您很可能通过不同的依赖项导入了不同的版本作为子依赖项。

You most likely have different versions imported through different dependencies as sub-dependencies.

您可以让maven向您展示所谓的有效pom,它将为您提供完整的依赖树,然后您可以从中看到包含的内容。

You can get maven to show you the so-called "effective pom" which will give you the full dependency tree, from which you can then see where what's included.

某些IDE(如IntelliJ)可以选择以图形方式显示,这样可以更容易地发现这样的冲突。

Some IDEs (like IntelliJ) have an option to show this graphically, which makes finding conflicts like this a lot easier.

排除较低版本,如果需要,可以明确地将依赖项添加到较新版本。

Exclude lower versions, and if required explicitly add dependencies to newer versions.

这篇关于由于java.lang.NoClassDefFoundError无法运行代码:com / fasterxml / jackson / annotation / JsonMerge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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