当前使用版本(必填,否则不予处理)

3.3.2

该问题是如何引起的?(确定最新版也有问题再提!!!)

1、配置 @EnableTransactionManagement public class VrCoreContractApplication { public static void main(String[] args) { SpringApplication.run(VrCoreContractApplication.class, args); } }

重写了insertOrUpdateBatch @Transactional(rollbackFor = Exception.class) public boolean insertOrUpdateBatch(Collection entityList, int batchSize, String method) { String sqlStatement = this.sqlStatement(method); return this.executeBatch(entityList, batchSize, (sqlSession, entity) -> { sqlSession.insert(sqlStatement, entity); }); }

重现步骤(如果有就写完整)

报错信息

每次批量操作有warn日志 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl#executeBatch(java.util.function.Consumer) warn日志:SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@19b5e305] was not registered for synchronization because DataSource is not transactional

Comment From: ppx-build-code

你的数据源是否和sqlsessionFactory绑定?

Comment From: huayanYu

检查事务的配置或者切面,或者是否是外层没事务,然后内部调用。

Comment From: qrqhuang

我的正好是内部调用造成的事务注解没生效。 this.updateBatchById