我试图在我的java项目中使用Jodd的Jerry模块,因为我下载了 jodd-lagarto- 3.4.5 jar并在classpath中添加。我开始编写如下代码。
public void testJerryParserCreation() {
Jerry.JerryParser jerryParser = Jerry.jerry();
((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXmlMode();
Jerry doc = jerryParser.parse("<xml> <book isbn='123'> <name>Foo<br></name> </book></xml>");
Jerry name = doc.$("book name");
assertEquals("Foo", name.text());
assertEquals("<xml><book isbn=\"123\"><name>Foo<br></br></name></book></xml>", doc.html());
}
但是在第一行本身的上述测试中,它给出了以下异常。这可能是错的。我的罐子不正确吗?
java.lang.NoClassDefFoundError: jodd/exception/UncheckedException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at jodd.jerry.Jerry$JerryParser.createLagartoDOMBuilder(Jerry.java:82)
at jodd.jerry.Jerry$JerryParser.<init>(Jerry.java:75)
at jodd.jerry.Jerry.jerry(Jerry.java:123)
at com.veersoft.JerryParserTest.testJerryParserCreation(JerryParserTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
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)
Caused by: java.lang.ClassNotFoundException: jodd.exception.UncheckedException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 39 more
答案 0 :(得分:1)
它的简单:) jodd-lagarto
模块取决于具有缺失类的jodd-core
模块(以及Lagarto正在使用的其他工具)。检查download page以查看所有模块和依赖项。对于您的版本,可能还会依赖slf4j
记录器(最近已将其删除)。
您也可以考虑使用一些依赖关系管理工具,例如 gradle 或 maven 。将自动下载所有依赖项。
如果可能,请尝试使用最新版本的 Jodd :)此时它是3.4.10; 3.5差不多了。新版本包含一些与Lagarto相关的重要改进,修复和性能提升:)享受!