@Transactional(rollbackFor = Throwable.class)
时间: 2023-08-17 16:11:57 浏览: 195
@Transactional(rollbackFor = Throwable.class)是一个注解,用于标记一个方法或类需要进行事务管理。它的作用是在方法执行前开启一个事务,在方法执行后根据情况进行提交或回滚。\[1\]在引用的代码中,@Transactional注解被用于方法上,表示该方法需要进行事务管理。同时,还可以设置一些属性,如readOnly、propagation和rollbackFor等,来指定事务的行为。\[2\]在异常处理中,可以使用TransactionAspectSupport.currentTransactionStatus().setRollbackOnly()来手动回滚事务,或者直接抛出异常来触发事务回滚。\[3\]
#### 引用[.reference_title]
- *1* [rollbackFor = Throwable.class 啥意思?](https://blog.csdn.net/xinqinglhj/article/details/51038591)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v4^insert_chatgpt"}} ] [.reference_item]
- *2* [@Transactional 踩坑记录(不生效,并发,回滚问题)](https://blog.csdn.net/JinglongSource/article/details/105026665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v4^insert_chatgpt"}} ] [.reference_item]
- *3* [Springboot @Transactional捕获异常事务回滚](https://blog.csdn.net/z446981439/article/details/103977668)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v4^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文