例如
@Transactional(rollbackFor = Exception.class) public String test(){ try{ ...... }catch(Exception e){ e.printStackTrace(); return ""; } return ""; }
事务是无法回滚的,我们需在catch中加上:
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
就可以了!