编程语言
首页 > 编程语言> > 造成原因:java.lang.NoClassDefFoundError:com_atlassian_clover / TestNameSniffer

造成原因:java.lang.NoClassDefFoundError:com_atlassian_clover / TestNameSniffer

作者:互联网

在启用三叶草配置文件的情况下调用TestNG单元测试用例时出现以下错误.没有更改任何三叶草版本.没有任何线索为什么发生.

这是我的库详细信息-clover-4.0.3,testng-6.0.1,maven 3

Caused by: java.lang.NoClassDefFoundError: com_atlassian_clover/TestNameSniffer
at com.mds404.catalog.infrastructure.entity.ModelBase.<clinit>(ModelBase.java:27)
at sun.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:111)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:51)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:52)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:41)
at org.mockito.Mockito.mock(Mockito.java:1014)
at org.mockito.Mockito.mock(Mockito.java:909)
at com.mds404.rest.v2.controller.BaseControllerTest.<init>(BaseControllerTest.java:107)
... 33 more
Caused by: java.lang.ClassNotFoundException: com_atlassian_clover.TestNameSniffer
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
... 46 more

解决方法:

错误

Caused by: java.lang.NoClassDefFoundError: com_atlassian_clover/TestNameSniffer

意味着类路径上缺少三叶草JAR(com.atlassian.clover:clover).

这通常是由两个问题引起的:

>缺少com.atlassian.clover:clover依赖性.请注意,Clover Maven插件会自动(在构建过程中)将此依赖项添加到项目中.但是,在某些情况下,您必须手动将此依赖项添加到其他Maven插件-通常添加到派生新JVM的插件中,例如用于容器内测试.
> Build在禁用Clover的情况下运行,但仍因该错误而失败.如果您在通过“ clover:setup”启用了Clover的情况下运行构建,并且下次创建(或部署)了JAR,则通常会发生这种情况.当您再次运行构建时,但是这次禁用了Clover,则构建可以从〜/ .m2缓存中获取这些JAR.由于这些JAR包含检测代码,并且缺少com.atlassian.clover:clover,因此构建将失败.要解决此问题,请清理〜/ .m2缓存,不要将“ clover:setup”与“ install”或“ deploy”一起使用.

参考:

> https://confluence.atlassian.com/cloverkb/noclassdeffounderror-com_atlassian_clover-coveragerecorder-317196439.html

干杯
马雷克

标签:maven,mockito,clover,java
来源: https://codeday.me/bug/20191111/2022627.html