spring 加trycatch不支持事物回滚
TransactionAspectSupport.class
原因:invoke方法:
try {
//执行事物:这里如果方法没有抛出异常继续执行
result = invocation.proceedWithInvocation();
} catch (Throwable var17) {
//捕获到异常回滚
this.completeTransactionAfterThrowing(txInfo, var17);
throw var17;
} finally {
//清除信息
this.cleanupTransactionInfo(txInfo);
}
//提交事物
this.commitTransactionAfterReturning(txInfo);
处理方法一:catch抛出异常:
处理方法二:catch设置手动回滚:TransactionAspectSupport.currentTransactionStatus()
.setRollbackOnly();
---------------------
作者:火锅技术栈
来源:CSDN
原文:https://blog.csdn.net/hotpots/article/details/80382216
版权声明:本文为博主原创文章,转载请附上博文链接!