SpringBoot(十):SpringBoot的简单事务管理
SpringBoot集成Mybatis之后,进行事务管理。SpringBoot使用事务非常简单,底层依然采用的是Spring本身提供的事务。
1.在入口类中使用注解@EnableTransactionManagement 开启事务支持

2.在访问数据库的Service方法上添加注解@Transactional 即可

controller层代码

运行测试 抛出异常 没修改成功

后续更新集成redis dubbox等
SpringBoot集成Mybatis之后,进行事务管理。SpringBoot使用事务非常简单,底层依然采用的是Spring本身提供的事务。
1.在入口类中使用注解@EnableTransactionManagement 开启事务支持

2.在访问数据库的Service方法上添加注解@Transactional 即可

controller层代码

运行测试 抛出异常 没修改成功

后续更新集成redis dubbox等