问题
在Spring OXM(对象XML映射),将对象转换为XML文件时,它会产生以下错误信息:
Caused by: java.lang.ClassNotFoundException: org.exolab.castor.xml.XMLException 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 java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 29 more
castor数据绑定包含在Spring OXM框架?
解决
castor 是一种可选的依赖于spring-oxm.jar,用castor来编组或在Spring OXM解组XML,添加该Spring依赖到 Maven pom.xml 文件。
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>3.0.5.RELEASE</version> </dependency> <!-- Uses Castor for XML --> <dependency> <groupId>org.codehaus.castor</groupId> <artifactId>castor</artifactId> <version>1.2</version> </dependency> <!-- Castor need this --> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.8.1</version> </dependency> </dependencies>