报错:

28-Oct-2024 15:35:35.972 严重 [main] com.sun.xml.bind.v2.util.XmlFactory.createParserFactory null
	org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing
		at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source)
		at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source)
		at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
		at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source)
		at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source)
		at com.sun.xml.bind.v2.util.XmlFactory.createParserFactory(XmlFactory.java:136)
		at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(UnmarshallerImpl.java:154)
		at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
		at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214)

tomcat里面使用dom4j解析xml一直报上面这个错,不确定原因是啥,换tomcat、jdk版本,排pom冲突没解决,由于系统太冗余不适合太多调整,可以通过下面这个全局属性替换默认xml解析器。

第二个参数是个解析器路径,不固定,在代码报错之前的位置,输入SAXParserFactory,看看代码提示有哪些相近的解析器,一个个试试,换个管用的

System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");

更多推荐