public class Dom4jTest {
@Test //获取xml文档第三本书的<WRITER>LESLIE CHEUNG</WRITER>
public void test1() throws DocumentException {
System.out.println("1");
SAXReader reader = new SAXReader();
System.out.println("2");
Document docu = reader.read(new File("E://hedwig//lomboz//javaweb30//1.xml"));
Element root = docu.getRootElement();
Element ele = (Element)root.element("BOOKSHELF").elements("BOOK").get(2);
String value = ele.element("WRITER").getText();
System.out.println(value);
}
无论是直接运行,
还是在“System.out.println(“1”); ”处标记breakpoint后debug,都直接报错。
Class not found Dom4jTest
java.lang.ClassNotFoundException: Dom4jTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:425)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
检查过,该程序保存的目录在classpath中。怎么破??