在Maven项目中进行单元测试,但mvn clean后重新mvn install项目,再次进行单元测试,会有以下的错误,
<span style="font-family:KaiTi_GB2312;font-size:18px;">Class not found com.core.order.service.impl.OrderServiceImplTest java.lang.ClassNotFoundException: com.core.order.service.impl.OrderServiceImplTest at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)</span>
很奇怪,感觉是将工程中的.class文件删除,mvn install又没有重新编译生成。
可以通过
eclipse->project->clean
重新编译下,再次运行单元测试就可以成功了。
时间: 2024-11-24 12:40:44