小编pav*_*van的帖子

读取xlsx文件时出现apache POI异常

我正在使用apache POI 通过添加以下依赖项来读取xlsx文件

<dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.8</version>
        </dependency>

<dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.5.0</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

即使部署在tomcat中,我也会在使用jetty插件运行时遇到异常.

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
    at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
    at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
    at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
......

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
...........
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument$Factory.parse(Unknown Source)
    at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:121)
    at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:92)
    ... 186 more
Run Code Online (Sandbox Code Playgroud)

我删除了xmlbeans依赖,因为maven将自动下载poi依赖项,仍然是同样的异常.任何帮助?

java exception apache-poi

10
推荐指数
2
解决办法
2万
查看次数

java中的异步HTTP请求

如何在java中发送异步HTTP GET/POST请求而不等待/读取响应?我不想使用任何第三方库..

java post get http urlconnection

9
推荐指数
1
解决办法
9647
查看次数

标签 统计

java ×2

apache-poi ×1

exception ×1

get ×1

http ×1

post ×1

urlconnection ×1