我是在安卓中使用的,通过Debug查看后发现3.1.0和3.1.1版本的BeanMap都是使用org.springframework.cglib.beans.BeanMap里面的BeanMap,在3.1.0和3.1.1版本项目中没有使用这个com.alibaba.excel.support.cglib.beans.BeanMap,导致我无法应用在安卓中,希望可以更改一下这个依赖包
触发Bug的代码
EasyExcel.write(fileName, History.class)
.sheet("模板1")
.doWrite(historyList);
实体类
public class History {
/**
* 主键
*/
@ExcelIgnore
private Integer id;
/**
* 在/离线模式
*/
@ExcelProperty(value = "在/离线模式")
private Integer mode;
/**
* 扫码模式
*/
@ExcelProperty(value = "扫码模式")
private Integer code;
public History() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getMode() {
return mode;
}
public void setMode(Integer mode) {
this.mode = mode;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
异常提示
E/WM-WorkerWrapper: Work [ id=26e7ed59-50fb-4c06-9d7f-4a918fedaac5, tags={ com.gzxn.pda.service.worker.ExportExcelWorker } ] failed because it threw an exception/error
java.util.concurrent.ExecutionException: com.alibaba.excel.exception.ExcelGenerateException: java.lang.ExceptionInInitializerError
at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:284)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: com.alibaba.excel.exception.ExcelGenerateException: java.lang.ExceptionInInitializerError
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:65)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:70)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:47)
at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)
at com.gzxn.pda.service.worker.ExportExcelWorker.doWork(ExportExcelWorker.java:90)
at androidx.work.Worker$1.run(Worker.java:85)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ExceptionInInitializerError
at com.alibaba.excel.util.BeanMapUtils.create(BeanMapUtils.java:25)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addJavaObjectToExcel(ExcelWriteAddExecutor.java:144)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addOneRowOfDataToExcel(ExcelWriteAddExecutor.java:82)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.add(ExcelWriteAddExecutor.java:58)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:59)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:70)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:47)
at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)
at com.gzxn.pda.service.worker.ExportExcelWorker.doWork(ExportExcelWorker.java:90)
at androidx.work.Worker$1.run(Worker.java:85)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: com.alibaba.excel.support.cglib.core.CodeGenerationException: java.lang.UnsupportedOperationException-->can't load this type of class file
at com.alibaba.excel.support.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:558)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
at com.alibaba.excel.support.cglib.core.KeyFactory$Generator.create(KeyFactory.java:237)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:184)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:164)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:156)
at com.alibaba.excel.support.cglib.beans.BeanMap$Generator.<clinit>(BeanMap.java:66)
at com.alibaba.excel.util.BeanMapUtils.create(BeanMapUtils.java:25)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addJavaObjectToExcel(ExcelWriteAddExecutor.java:144)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addOneRowOfDataToExcel(ExcelWriteAddExecutor.java:82)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.add(ExcelWriteAddExecutor.java:58)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:59)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:70)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:47)
at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)
at com.gzxn.pda.service.worker.ExportExcelWorker.doWork(ExportExcelWorker.java:90)
at androidx.work.Worker$1.run(Worker.java:85)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
at java.lang.ClassLoader.defineClass(ClassLoader.java:591)
at java.lang.reflect.Method.invoke(Native Method)
at com.alibaba.excel.support.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:555)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:363)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at com.alibaba.excel.support.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134)
at com.alibaba.excel.support.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
at com.alibaba.excel.support.cglib.core.KeyFactory$Generator.create(KeyFactory.java:237)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:184)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:164)
at com.alibaba.excel.support.cglib.core.KeyFactory.create(KeyFactory.java:156)
at com.alibaba.excel.support.cglib.beans.BeanMap$Generator.<clinit>(BeanMap.java:66)
at com.alibaba.excel.util.BeanMapUtils.create(BeanMapUtils.java:25)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addJavaObjectToExcel(ExcelWriteAddExecutor.java:144)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addOneRowOfDataToExcel(ExcelWriteAddExecutor.java:82)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.add(ExcelWriteAddExecutor.java:58)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:59)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:70)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:47)
at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)
at com.gzxn.pda.service.worker.ExportExcelWorker.doWork(ExportExcelWorker.java:90)
at androidx.work.Worker$1.run(Worker.java:85)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
I/WM-WorkerWrapper: Worker result FAILURE for Work [ id=26e7ed59-50fb-4c06-9d7f-4a918fedaac5, tags={ com.gzxn.pda.service.worker.ExportExcelWorker } ]
提示的异常或者没有达到的效果