如果你在使用Spring加载xml文件时出现下面的错误:
javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@50c4fe76] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
你可以首先考虑是否存在xerces jar包冲突,可以查找有哪些jar包里面包括DocumentBuilderFactoryImpl这个类。
我的项目中出现该错误的原因就是因为同时存在两个jar包中含有该类:xerces-1.2.3.jar和xercesImpl-2.6.2.jar,后者是我们需要的jar,但是由于某种原因xerces-1.2.3.jar在classpaht中的位置靠前,所以产生以上的错误。
因为项目中用到了maven,xercesImpl-2.6.2.jar是在pom.xml直接依赖的,而xerces-1.2.3.jar是由于引入了camel-jxpath而间接被引入的,所以一种解决方案是在camel-jxpath的依赖中加入exclusion以去掉对xerces-1.2.3.jar的引用:
<dependency>
<groupId>org.apache.camel</groupId>