【提问】Springboot使用@Async多线程分批次插入数据报错-Java专区论坛-技术-SpringForAll社区

提问Springboot使用@Async多线程分批次插入数据报错

     在导入数据的时候,因为数据量过大,想使用多线程分批次插入数据库,使用了@Async注解直接使用线程池,但是在执行mybatis插入的时候会报错,想问下是怎么原因造成的呢?代码逻辑很简单如下。

2022-06-22 10:25:51.882 ERROR 24776 — [TaskExecutor-20] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public java.lang.String com.ruoyi.pmc.service.impl.BatteryInventoryImpl.importBatteryInventory(java.util.List,java.lang.Boolean)

com.ruoyi.common.exception.CustomException: 很抱歉,导入失败!共 1000 条数据格式不正确,错误如下:<br/>1、工厂&物料号 XAL112955680-00 导入失败:nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.ruoyi.common.exception.CustomException: 获取用户信息异常
### The error may exist in com/ruoyi/pmc/mapper/BatteryInventoryMapper.java (best guess)
### The error may involve com.ruoyi.pmc.mapper.BatteryInventoryMapper.insert
### The error occurred while executing an update
### Cause: com.ruoyi.common.exception.CustomException: 获取用户信息异常<br/>2、工厂&物料号 XAL112893424-00 导入失败:nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.ruoyi.common.exception.CustomException: 获取用户信息异常
### The error may exist in com/ruoyi/pmc/mapper/BatteryInventoryMapper.java (best guess)
### The error may involve com.ruoyi.pmc.mapper.BatteryInventoryMapper.insert
### The error occurred while executing an update
### Cause: com.ruoyi.common.exception.CustomException: 获取用户信息异常<br/>3、工厂&物料号 SX2013546940-00 导入失败:nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: com.ruoyi.common.exception.CustomException: 获取用户信息异常

省略号……

企业微信截图_16558642344699

企业微信截图_16558643175926

 

 

 

请登录后发表评论