@Transactional(rollbackFor = Exception.class)
public void except() {
//事务完成后提交
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
//提交后, 指正常结束
@Override
public void afterCommit() {
//doSomething
}
;
//执行完成后, 可以是提交 也可以是回滚
@Override
public void afterCompletion(int status) {
if (status == TransactionSynchronization.STATUS_ROLLED_BACK) {
log.info("=============!回滚===================");
//do
}
}
});
}