@Transactional(propagation = Propagation.REQUIRED) public void accountMoney7() { ordersDao.lessMoney(); transMethod7(); int x = 1 / 0; } @Transactional(propagation = Propagation.REQUIRES_NEW) public void transMethod7() { ordersDao.moreMoney(); }
因为accountMoney7 已经开启事务,并且propagation = Propagation.REQUIRED, 按照事务的传播机制,执行 transMethod7 不会再开启新的事务,所以发生异常时 还是会回滚