问题

使用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)
	//...

Maven中的Castor依赖关系。

<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>

翻译自: https://mkyong.com/spring3/classnotfoundexception-org-apache-xml-serialize-xmlserializer/

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐