Tôi đang sử dụng apache POI để đọc xlsx file bằng cách thêm dưới đây phụ thuộcapache POI ngoại lệ trong file xlsx đọc
<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>
tôi nhận được sau khi chạy ngoại lệ với plugin cầu cảng thậm chí nếu được triển khai trong tomcat.
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
Tôi đã xóa phụ thuộc xmlbeans làm maven sẽ tự động tải xuống phụ thuộc poi, vẫn là ngoại lệ tương tự.Bất kỳ trợ giúp nào?
Cũng đã nhận lỗi này sử dụng '3.11' và '3.12 beta' – Guus
Bạn hãy thử [đọc FAQ entry Apache POI về chủ đề này] (http://poi.apache.org/faq.html#faq-N10025)? – Gagravarr