Open xu-xiwei opened 5 years ago
我也遇到类似问题 @Transactional加上类似readOnly=true
,propagation = Propagation.SUPPORTS
,虽然不创建Spring事务,但是提交的时候由于 MySQL 默认的autocommit导致数据还是入库。
你查看一下源码,其实根本没有这个属性。另外MySQL官方也提到了,autocommit
是默认开启的。
In InnoDB, all user activity occurs inside a transaction. If autocommit mode is enabled, each SQL statement forms a single transaction on its own. By default, MySQL starts the session for each new connection with autocommit enabled ...
如果你实在想要操作, 建议在MySQL的配置文件做类似如下设置:
init_connect='set autocommit=0'
这样连接上的客户端默认都是关闭的
spring.datasource.druid.default-auto-commit=false 项目用springboot+mybatis 想把事务自动提交关闭,service不开启事务,insert还是能插入。这个有什么用呢