使用org.jdom2.input.SAXBuilder:
final SAXBuilder builder = new SAXBuilder();
时出现异常:
java.lang.ExceptionInInitializerError
at org.jdom2.input.SAXBuilder.<init>(SAXBuilder.java:338)
at org.jdom2.input.SAXBuilder.<init>(SAXBuilder.java:221)
解决办法有两种:
-
在JVM启动之时加入参数:
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
-
在new SAXBuilder()前加入:
System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");