NoClassDefFoundError: javax/xml/stream/XMLStreamException [英] NoClassDefFoundError: javax/xml/stream/XMLStreamException

查看:16
本文介绍了NoClassDefFoundError: javax/xml/stream/XMLStreamException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 Apache POI 编写 .xlsx 文件时遇到以下异常

I am getting the following exception while trying to write an .xlsx file using Apache POI

NoClassDefFoundError: javax/xml/stream/XMLStreamException

这是代码片段:-

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();

我有以下罐子

  • 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.

推荐答案

你缺少 stax API jar

You're missing the stax API jar

如果您查看 POI 组件页面,您会看到 ooxml-schemas jar依赖于 STAX API jar(通常由 stax-api-1.0.1.jar 提供)

If you look at the POI Components page you'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-lib 目录中,您将看到您需要的 jar.或者,如果您使用 Maven,它会为您下载依赖项

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

这篇关于NoClassDefFoundError: javax/xml/stream/XMLStreamException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆