首页 > 代码库 > Spring项目JUnit测试报错ClassNotFoundException解决、
Spring项目JUnit测试报错ClassNotFoundException解决、
MyEclipse项目上有红色感叹号,各包显示正常。用JUnit测试部分能运行,部分报错,报错如下:
Class not found n_jdbc.UserDaoTest
java.lang.ClassNotFoundException: n_jdbc.UserDaoTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
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)
解决:
在Window----->Preferences下---->Java---->Compiler---->Building 页面 :
修改如下两项属性:error---->Warning
修改后为:
再次运行正常,原因还没弄明白。
Spring项目JUnit测试报错ClassNotFoundException解决、