java.lang.NoClassDefFoundError: org/objenesis/ObjenesisStd


解决方案收集,可行  
ClassNotFoundException is result of a class loader that is not able to load a particular class.

In your case Mockito has a transitive dependency to Objenesis (it needs Objenesis for correct behavior). You are most likely trying to execute your test with Mockito on test class path, but without Objenesis.

You need to add Objenesis to your test class path.

For maven projects, be sure that:

you have declared Mockito as test dependency
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.10.19</version>
    <scope>test</scope>
</dependency>
to run a particular test from the command line execute
mvn test -Dtest=fullyQualifedNameToYourTestClass

猜你喜欢

转载自wobenqinren.iteye.com/blog/2348512