行业知识
java.lang.illegalArgumentException: Source must not be null
2026-12-06 17:01:00
来源:互联网转载
修订记录:
| 内容 | 时间 |
| 修改错误结论 | 2024.1.14 |
()
在代码中某个方法或操作的参数传递了一个空的、不允许为空的参数。这个异常通常在方法中检查到参数为 null 时抛出。
之前的错误结论是认为:easyexcal中第一列参数为空会出现这个报错
()但经过后期测试原因并不是这个
在ExcelUtils类中有这个方法
源列表中的每个对象的属性值复制到目标列表的对应对象中
在这个过程中BeanUtils.copyProperties(source, target);
当copy的source为空则会报错
批量导出的时候只要有一条数据为空就会报错
public static void exportExcelToTarget(List sourceList, Class targetClass) throws Exception { List targetList = new ArrayList(sourceList.size()); for(Object source : sourceList){ Object target = targetClass.newInstance(); BeanUtils.copyProperties(source, target); targetList.add(target); } } 建议检查数据库数据是否正确
下一篇:战舰不上服务器怎么解决?