1、sql语句里foreach循环拼接
2、foreach循环里拼接sql, 以;分割
3、利用mybatis批处理,批量提交
//添加 SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); QuartzTaskMapper mapper = sqlSession.getMapper(QuartzTaskMapper.class); try { statisticsList.forEach(ecodeStatistics -> mapper.updateStatistics(ecodeStatistics)); sqlSession.commit(); } catch (Exception e) { sqlSession.rollback(); e.printStackTrace(); } finally { sqlSession.close(); }