Mybatis 事物回滚
添加注解 @Transactional
如果flag经过一系列操作为false,事务回滚
@Transactional @RequestMapping(value = "/test") public Result test(@RequestBody Abc aaa) { Abc abc = sysService.getById(aaa.getId()); if (null == abc || null == abc) { return ResultUtil.sendErrorMessage("失败!"); } sysService.save(aaa); boolean flag = false; …… …… if (flag) { return ResultUtil.sendSuccessMessage("成功!"); } else { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); return ResultUtil.sendErrorMessage("失败!"); } }