【EasyExcel】使用easyExcel过程中,项目报错的解决集合

 

报错:Can not close IO

[ERROR] 2019-11-02 13:51:21.210 [ProExportSkuDataJob-1455-TaskThread-1] [com..proengine.domain.common.util.DpeLogUtil] [] - fd3f7b29-20191102134946773,dpePartner#ProExportSkuDataJob   Job execute fail,errMsg= com.alibaba.excel.exception.ExcelGenerateException: Can not close IO
    at com.alibaba.excel.context.WriteContextImpl.throwCanNotCloseIo(WriteContextImpl.java:390)
    at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:352)
    at com.alibaba.excel.write.ExcelBuilderImpl.finish(ExcelBuilderImpl.java:106)
    at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:98)
    at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:155)
    at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:140)
    at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:134)
    at com..proengine.partner.export.job.ProExportSkuDataJob.createXlsxFile2(ProExportSkuDataJob.java:178)
    at com..proengine.partner.export.job.ProExportSkuDataJob.executeTask(ProExportSkuDataJob.java:83)
    at com..dispatcher.sdk.task.AbstractSimpleTask.execute(AbstractSimpleTask.java:56)
    at com..dispatcher.sdk.thread.TaskExecuteThread.run(TaskExecuteThread.java:59)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Workbook.close()V
    at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:350)
    ... 12 more

 

 

解决方法:

将项目中pom.xml中依赖的  POI相关的版本升级到  3.17以上  【easyexcel版本  2.0.5】

我自己将POI版本升级到了4.1.0

 

 

 

 

 

 

报错:

java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class

Could not initialize class net.sf.cglib.beans.BeanMap$Generator

 

com.alibaba.excel.exception.ExcelGenerateException: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class
    at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:99)
    at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:155)
    at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:140)
    at com..proengine.partner.export.job.ProExportSkuDataJob.createXlsxFile2(ProExportSkuDataJob.java:182)
    at com..proengine.partner.export.job.ProExportSkuDataJob.executeTask(ProExportSkuDataJob.java:83)
    at com..dispatcher.sdk.task.AbstractSimpleTask.execute(AbstractSimpleTask.java:56)
    at com..dispatcher.sdk.thread.TaskExecuteThread.run(TaskExecuteThread.java:59)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2567)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:859)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1302)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    at net.sf.cglib.core.DefaultGeneratorStrategy.getClassVisitor(DefaultGeneratorStrategy.java:30)
    at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.beans.BeanMap$Generator.<clinit>(BeanMap.java:64)
    at net.sf.cglib.beans.BeanMap.create(BeanMap.java:56)
    at com.alibaba.excel.write.ExcelBuilderImpl.addJavaObjectToExcel(ExcelBuilderImpl.java:201)
    at com.alibaba.excel.write.ExcelBuilderImpl.addOneRowOfDataToExcel(ExcelBuilderImpl.java:128)
    at com.alibaba.excel.write.ExcelBuilderImpl.doAddContent(ExcelBuilderImpl.java:79)
    at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:93)
    ... 9 more

 

 

解决方法:

是因为项目中有cglib的jar包  和 asm的jar包冲突。解决掉jar包冲突即可。

 

解决jar包冲突的方法:

https://www.cnblogs.com/sxdcgaq8080/p/11791897.html

 

posted @ 2019-11-04 14:31  Angel挤一挤  阅读(31686)  评论(2编辑  收藏  举报