java NoClassDefFoundError: javax/xml/stream/XMLStreamException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7400096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NoClassDefFoundError: javax/xml/stream/XMLStreamException
提问by Vivek
I am getting the following exception while trying to write an .xlsx file using Apache POI
我在尝试编写一个 .xlsx file using Apache POI
NoClassDefFoundError: javax/xml/stream/XMLStreamException
Here's the Code Snippet:-
这是代码片段:-
XSSFWorkbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(100);
FileOutputStream fileOut = new FileOutputStream("D:\workspace\April\Excel Test\workbook.xlsx");
wb.write(fileOut);
fileOut.close();
I have the following jars included
我包括以下罐子
- dom4j-1.6.1
- poi-ooxml-3.5-FINAL
- poi-3.6-20091214
- xmlbeans-2.3.0
- ooxml-schemas-1.0
- dom4j-1.6.1
- poi-ooxml-3.5-FINAL
- poi-3.6-20091214
- xmlbeans-2.3.0
- ooxml-schemas-1.0
Please let me know what i am doing wrong here or i am missing something.
请让我知道我在这里做错了什么,或者我遗漏了什么。
采纳答案by Gagravarr
You're missing the stax API jar
您缺少 stax API jar
If you look at the POI Components pageyou'll see that the ooxml-schemas jar depends on a STAX API jar (most typically provided by stax-api-1.0.1.jar
)
如果您查看POI 组件页面,您将看到 ooxml-schemas jar 依赖于 STAX API jar(通常由 提供stax-api-1.0.1.jar
)
Look in your POI binary download, and in the ooxml-lib
directory you'll see the jar you need. Alternately, if you use Maven, it'll download the dependency for you
查看您的 POI 二进制文件下载,在ooxml-lib
目录中您将看到您需要的 jar。或者,如果您使用 Maven,它会为您下载依赖项