EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File

简介: EasyExcel导入的时候报错Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/File

今天用EasyExcel导入的时候报错,如下

com.alibaba.excel.exception.ExcelAnalysisException: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/FileMagic

   at com.alibaba.excel.analysis.ExcelAnalyserImpl.<init>(ExcelAnalyserImpl.java:57)

   at com.alibaba.excel.ExcelReader.<init>(ExcelReader.java:145)

   at com.alibaba.excel.read.builder.ExcelReaderBuilder.build(ExcelReaderBuilder.java:193)

   at com.alibaba.excel.read.builder.ExcelReaderBuilder.sheet(ExcelReaderBuilder.java:229)

   at com.alibaba.excel.read.builder.ExcelReaderBuilder.sheet(ExcelReaderBuilder.java:217)

   at test.jifen.ZJpsbcTest.parseExcel(ZJpsbcTest.java:267)

   at test.jifen.ZJpsbcTest.test1(ZJpsbcTest.java:190)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

   at java.lang.reflect.Method.invoke(Method.java:498)

   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

   at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

   at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

   at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

   at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)

   at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)

   at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Caused by: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/FileMagic

   at com.alibaba.excel.support.ExcelTypeEnum.recognitionExcelType(ExcelTypeEnum.java:90)

   at com.alibaba.excel.support.ExcelTypeEnum.valueOf(ExcelTypeEnum.java:78)

   at com.alibaba.excel.analysis.ExcelAnalyserImpl.choiceExcelExecutor(ExcelAnalyserImpl.java:62)

   at com.alibaba.excel.analysis.ExcelAnalyserImpl.<init>(ExcelAnalyserImpl.java:51)

   ... 29 more

Caused by: java.lang.ClassNotFoundException: org.apache.poi.poifs.filesystem.FileMagic

   at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

   ... 33 more

 

解决方法:

从maven仓库引入依赖,地址如下

https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas/3.17

除了引入easyexcel,还要引入poi,并且三个poi版本要一致。

poi,poi-ooxml,poi-ooxml-schemas 的版本号要一致

 

 
        <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>2.2.6</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.17</version>
        </dependency>

相关文章
|
10月前
|
Android开发
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
556 4
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
|
9月前
|
Java API 开发工具
【Azure Developer】Java代码实现获取Azure 资源的指标数据却报错 "invalid time interval input"
在使用 Java 调用虚拟机 API 获取指标数据时,因本地时区设置非 UTC,导致时间格式解析错误。解决方法是在代码中手动指定时区为 UTC,使用 `ZoneOffset.ofHours(0)` 并结合 `withOffsetSameInstant` 方法进行时区转换,从而避免因时区差异引发的时间格式问题。
393 4
|
8月前
|
JSON Java 数据格式
java调用服务报错400
java调用服务报错400
215 6
java调用服务报错400
|
8月前
|
JSON Java 数据格式
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
488 6
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
443 11
|
运维 Cloud Native Java
postman发起post请求遇到报错:java.io.FileNotFoundException (文件名、目录名或卷标语法不正确。)
遇到bug报错,多猜可能的原因,控制变量反复测试,直至找到问题的关键,然后再思考如何解决或者回避。 博客不应该只有代码和解决方案,重点应该在于给出解决方案的同时分享思维模式,只有思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来
|
8月前
|
人工智能 数据处理 API
阿里云、Ververica、Confluent 与 LinkedIn 携手推进流式创新,共筑基于 Apache Flink Agents 的智能体 AI 未来
Apache Flink Agents 是由阿里云、Ververica、Confluent 与 LinkedIn 联合推出的开源子项目,旨在基于 Flink 构建可扩展、事件驱动的生产级 AI 智能体框架,实现数据与智能的实时融合。
1363 6
阿里云、Ververica、Confluent 与 LinkedIn 携手推进流式创新,共筑基于 Apache Flink Agents 的智能体 AI 未来
|
存储 Cloud Native 数据处理
从嵌入式状态管理到云原生架构:Apache Flink 的演进与下一代增量计算范式
本文整理自阿里云资深技术专家、Apache Flink PMC 成员梅源在 Flink Forward Asia 新加坡 2025上的分享,深入解析 Flink 状态管理系统的发展历程,从核心设计到 Flink 2.0 存算分离架构,并展望未来基于流批一体的通用增量计算方向。
621 0
从嵌入式状态管理到云原生架构:Apache Flink 的演进与下一代增量计算范式
|
10月前
|
SQL 人工智能 数据挖掘
Apache Flink:从实时数据分析到实时AI
Apache Flink 是实时数据处理领域的核心技术,历经十年发展,已从学术项目成长为实时计算的事实标准。它在现代数据架构中发挥着关键作用,支持实时数据分析、湖仓集成及实时 AI 应用。随着 Flink 2.0 的发布,其在流式湖仓、AI 驱动决策等方面展现出强大潜力,正推动企业迈向智能化、实时化的新阶段。
1111 9
Apache Flink:从实时数据分析到实时AI

推荐镜像

更多