Spring boot中注解@Transactional无效

@wanqiuz 2018-04-21 09:39:32发表于 wanqiuz/blog-articles Spring Boottransaction

(1) @transactional引入的org.springframework.transaction.annotation.Transactional,而不是javax.transactional
(2) mysql关闭自动提交,即设置autocommit=0
查看autocommit设置

MariaDB [(none)]> select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

关闭autocommit

MariaDB [(none)]> set autocommit=off;

再查询一次

MariaDB [(none)]> select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
|            0 |
+--------------+
1 row in set (0.00 sec)

(3) 程序没有加事务控制
(4) mysql的驱动用 com.mysql.jdbc.Driver
(5) 用非root权限的普通权限的用户连接mysql