springboot学习总结六(Spring boot下事务配置管理)
SpringBoot事务支持:
1.在入口类中使用@EnableTransactionManagement开启事务支持;
2.在访问数据库的Service方法上添加注解@Transactional即可
StudentService.java
StudentServiceImpl.java
MyBaitsController.java
执行结果分析:
除数不能为零,会抛出运行时异常,上一步的结果就会回滚
数据库查询数据结果未改变:
把@Transactional注解去掉,数据库数据结果进行更新: