From b810b5c1388d72ced658f7ab5ca5cef5303bda21 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 9 Feb 2022 14:29:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/ModelBuildEventListener.java | 2 +- .../com/alibaba/excel/util/BeanMapUtils.java | 6 ++-- .../write/executor/ExcelWriteAddExecutor.java | 2 +- .../easyexcel/test/temp/Xls03Test.java | 4 +-- pom.xml | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java b/easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java index 057919e9..44f77513 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java @@ -15,8 +15,8 @@ import com.alibaba.excel.util.ClassUtils; import com.alibaba.excel.util.ConverterUtils; import com.alibaba.excel.util.MapUtils; -import net.sf.cglib.beans.BeanMap; import org.apache.commons.collections4.CollectionUtils; +import org.springframework.cglib.beans.BeanMap; /** * Convert to the object the user needs diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java index b089612b..30b2c692 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java @@ -23,9 +23,9 @@ public class BeanMapUtils { */ public static BeanMap create(Object bean) { BeanMap.Generator gen = new BeanMap.Generator(); - //gen.setBean(student); - //gen.setContextClass(Student.class); - BeanMap beanMap = gen.create(); + gen.setBean(bean); + gen.setContextClass(bean.getClass()); + gen.setNamingPolicy(EasyExcelNamingPolicy.INSTANCE); return gen.create(); } diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java b/easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java index 0bb4007c..459f0a7a 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java @@ -25,10 +25,10 @@ import com.alibaba.excel.write.metadata.RowData; import com.alibaba.excel.write.metadata.holder.WriteHolder; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; -import net.sf.cglib.beans.BeanMap; import org.apache.commons.collections4.CollectionUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; +import org.springframework.cglib.beans.BeanMap; /** * Add the data into excel diff --git a/easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java b/easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java index 906c092e..ffb590ee 100644 --- a/easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java +++ b/easyexcel-core/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java @@ -6,12 +6,12 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.fastjson.JSON; -import net.sf.cglib.beans.BeanMap; -import net.sf.cglib.core.DebuggingClassWriter; import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.cglib.core.DebuggingClassWriter; /** * 临时测试 diff --git a/pom.xml b/pom.xml index b6d002d0..cf150db3 100644 --- a/pom.xml +++ b/pom.xml @@ -385,6 +385,37 @@ + + + org.apache.maven.plugins + maven-shade-plugin + + + package + + shade + + + false + + + org.springframework:spring-core + + org/springframework/asm/** + org/springframework/cglib/** + + + + + + org.springframework + com.alibaba.easyexcel.support + + + + + +