Spring 事物抛出Exception 异常时事物没有回滚
来源:互联网 发布:广州恒大淘宝老板是谁 编辑:程序博客网 时间:2024/06/06 02:16
Spring 声明式事务 只针对 RuntimeException 异常抛出时才会回滚事物,如果时Exception 抛出时是不会回滚的。
如果想要让exception 抛出时也让事物回滚 则可以在spring 配置文件中添加 一个AOP 配置:
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" rollback-for="com.cn.exception.ChildrenException"/>
</tx:attributes>
</tx:advice>
这里的 ChildrenException 是实现了 Exception 类的子类。
或者可以定义 定义 不会滚的 异常:
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="update*" no-rollback-for="IOException"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
0 0
- Spring 事物抛出Exception 异常时事物没有回滚
- spring 事物异常回滚,捕获异常,不抛出就不会回滚
- spring事物异常回滚,捕获异常不抛出就不会回滚
- spring事物回滚机制 (事务异常回滚,捕获异常不抛出就不会回滚)
- spring事物异常回滚
- spring学习----spring事物异常回滚
- 异常捕获后不抛出,事物就不能回滚
- try{} catch(Exception e){}异常抛出与Spring事务回滚策略
- spring 抛出异常未能回滚解决方法
- spring事物回滚
- Spring事物回滚
- spring异常抛出触发事务回滚策略导读
- spring异常抛出触发事务回滚策略导读
- Spring异常抛出触发事务回滚策略
- 异常捕获不抛出,Spring事务无法回滚
- 异常捕获不抛出,Spring事务无法回滚
- 异常捕获不抛出,Spring事务无法回滚【转载】
- 异常捕获不抛出,Spring事务无法回滚
- LintCode :删除数字
- 详细讲述MySQL中的子查询操作
- NOIP 2007 提高组 复赛 expand 字符串的展开
- 新网站建设的完整步骤
- 深度理解z-index
- Spring 事物抛出Exception 异常时事物没有回滚
- python递归分治求最大子数组失败
- PHP编译安装时常见错误解决办法,php编译常见错误
- 设计模式概述及六大原则
- [参考资料] PB中字符编码转换[ansi, UTF8, Unicode]
- Lambada表达式
- java 中各种容器的使用
- jmeter随笔BeanShell 中时间函数__time()
- wampserver官网点击下载对话框不会下载