@Transactional中try-catch和this使用事务失效的解决方法

it2022-05-05  111

//通过获取当前代理对象来代替this的方法去解决this导致事务失效的问题 ((BaseWithdrawBillService<BaseWithdrawBillPo, CashServiceFace>) AopContext.currentProxy()).returnAliAmount(id);

// 解决在try-catch中无法回滚事务的问题

TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

最新回复(0)