问题
随着Spring OXM+ Castor数据绑定,Castor库添加,但仍出现以下错误消息?
Exception in thread "main" java.lang.RuntimeException: Could not instantiate serializer org.apache.xml.serialize.XMLSerializer: java.lang.ClassNotFoundException: org.apache.xml.serialize.XMLSerializer at org.exolab.castor.xml.XercesSerializer.<init>(XercesSerializer.java:50) //...
Castor 依赖于Maven。
<dependency> <groupId>org.codehaus.castor</groupId> <artifactId>castor</artifactId> <version>1.2</version> </dependency>
解决
如果要纠正这个错误,Castor 需要Xerces 工作,所以,也需要添加Xerces的依赖。
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>3.0.5.RELEASE</version> </dependency> <dependency> <groupId>org.codehaus.castor</groupId> <artifactId>castor</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.8.1</version> </dependency> </dependencies>