解决报错:org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing

报错:

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");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值