Spring事务回滚与异常

Spring的事务管理默认是针对unchecked exception回滚,也就是默认对Error异常和RuntimeException异常以及其子类进行事务回滚,且必须对抛出异常,若使用try-catch对其异常捕获则不会进行回滚,会把事物吞并!需要手动抛出运行时异常才会回滚(Error异常和RuntimeException异常抛出时不需要方法调用throws或try-catch语句);

checked异常,checked异常必须由try-catch语句包含或者由方法throws抛出,且事务默认对checked异常不进行回滚。

https://blog.csdn.net/zhouleiblog/article/details/82834178

https://www.cnblogs.com/leihuazhe/p/7735416.html

猜你喜欢

转载自blog.csdn.net/hanjungua8144/article/details/84389913