如何将这些 xml-apis.jar、stax-apis.jar 或 xercesImpl.jar : 放入我的 pom,xml

How do I put these xml-apis.jar, stax-apis.jar or xercesImpl.jar :to my pom,xml

我在 Apache POI 的 JIRA 插件上得到了这个 trece:

这是由 Apache POI 3.9 引起的:

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.poi.xssf.usermodel.XSSFWorkbook]:      
Constructor threw exception; nested exception is java.lang.NoSuchMethodError:     
javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory; at  
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at

Caused by: java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory; at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller

我从 Apache POI 查看了这个 FAQ http://poi.apache.org/faq.html#faq-N1017E

如何将这些 xml-apis.jar、stax-apis.jar 或 xercesImpl.jar : 放入我的 pom,xml 依赖项。

然后,您只需要在 "dependencies" 部分声明新的依赖项。这里有一个包含不同版本的目录,搜索您需要的版本并添加它们:

XML-蜜蜂:http://mvnrepository.com/artifact/xml-apis/xml-apis

Xerces:http://mvnrepository.com/artifact/xerces

Stax-apis:http://mvnrepository.com/artifact/stax/stax-api