使用Mybatis-plus可以很方便的实现批量新增和批量修改,不仅比自己写foreach遍历方便很多,而且性能也更加优秀。但是Mybatis-plus官方提供的批量修改和批量新增都是根据id来修改的,有时候我们需求其他字段,所以就需要我们自己修改一下。 在Mybatis-plus的IService接口中有updateBatchById方法,我们常用以下方法根据id批量修改数据。 @Transactional(rollbackFor = Exception.class) default boolean updateBatchById(Collection<T> entityList) { return updateBatchById(entityList, DEFAULT_BATCH_SIZE); } @Transactional(rollbackFor = Exception.class) @Override public boolean updateBatchById(Collection<T> entityList, int batchSize) { String...