Spring Boot中MyBatis事务

全局事务

在springboot启动类,加上@EnableTransactionManagement(proxyTargetClass = true)注解,因为我启动类没有实现接口且该注解底层实现用的是动态代理,所以要设置proxyTargetClass = true。

@EnableTransactionManagement(proxyTargetClass = true)

service层,要添加事务的方法

添加@Transactional注解,即代表该方法内操作是在一个事务里的

猜你喜欢

转载自blog.csdn.net/weixin_55806809/article/details/121235256
今日推荐