dom4j解析XML时出现"java.lang.noclassdeffounderror: org/jaxen/jaxenexception"错误

转自:linjx2004 的 《dom4j解析XML时出现"java.lang.noclassdeffounderror: org/jaxen/jaxenexception"错误》

原址:https://blog.csdn.net/linjx2004/article/details/5608897

使用dom4j解析XML时,要快速获取某个节点的数据,使用XPath是个不错的方法,dom4j的快速手册里也建议使用这种方式

执行时却抛出以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164)

这么好用的方法怎么能抛异常呢,一路跟踪过去看,竟然是“List l = doc.selectNodes("//COLS/COL1");”这句报错,查了一下才知道,不光要有dom4j这个包,还要有jaxen 包:<jaxen-1.1-beta-6.jar>-238 KB,这应该是dom4j的基础包,在dom4j的zip包的lib目录里可以找到。即使用这个方法需要以下两个包:

dom4j-1.6.1.jar-306 KB

jaxen-1.1-beta-6.jar-238 KB

猜你喜欢

转载自blog.csdn.net/yup1212/article/details/81119127