springboot 事务回滚

 

在springboot中,使用事务回滚时,添加@Transactional注解,然后在try-catch块中,发生异常时,在catch中

添加 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

构造异常场景

测试后查库发现,库中没有数据被删除

 

posted @ 2017-11-30 14:26  SayAndDo  阅读(3731)  评论(0编辑  收藏  举报