2
我們在代碼中導致測試失敗時,將JAVA_HOME設置爲JDK7而不是JDK6(maven with source/target = 1.6)JDK6 - > JDK7無法使用com.sun.xml.internal.stream.XMLInputFactoryImpl
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";
別的東西,但我不知道是什麼。
我說如果在JAVA_HOME環境中設置了JDK 6,應用程序是否正常運行? – AntJavaDev 2014-10-02 10:55:09
使用java內部類幾乎沒有好處。 「內部」的一點是,實施可能會在沒有通知的情況下發生變化。 – 2014-10-02 10:55:23
查看「newFactory」的文檔,它可能會給你一個關於如何找到合理替換的想法。 http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html#newFactory() – 2014-10-02 10:59:24