我们在代码中有以下情况,当 JAVA_HOME 设置为 JDK7 而不是 JDK6(源/目标 = 1.6 的 Maven)运行时导致测试失败
javax.xml.stream.FactoryConfigurationError: Provider for com.sun.xml.internal.stream.XMLInputFactoryImpl cannot be found
at javax.xml.stream.XMLInputFactory.newFactory(XMLInputFactory.java:239)
代码本身
private static final String SUN_XML_INPUT_FACTORY = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
private final XMLInputFactory xmlInputFactory;
public theConstructor() {
// When deployed to WebLogic 10.3.5 it will use "weblogic.xml.stax.XMLStreamInputFactory" which will
// cause a StreamReader exception as it requires some input stream other than null.
xmlInputFactory = XMLInputFactory.newFactory(SUN_XML_INPUT_FACTORY, this.getClass().getClassLoader());
}
我想我应该使用其他东西,private static final String SUN_XML_INPUT_FACTORY = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
但我不知道是什么。