try catch捕获异常事务失效吗
时间: 2023-10-24 18:31:46 浏览: 89
在使用了 @Transactional 注解的业务方法内部使用 try-catch 语句并不会导致事务注解失效。尽管 try-catch 捕获了异常,但是事务仍然可以正常进行。事务注解会对整个业务方法生效,而不受 try-catch 捕获异常的影响。这是因为 try-catch 语句只是用来处理异常的一种方式,并不会影响事务的执行和回滚。所以,即使异常被捕获了,事务仍然会正常进行,而不会失效。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Java中Transactional注解业务方法里面try catch会导致事务注解失效吗](https://blog.csdn.net/weixin_35750953/article/details/129069723)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [try-catch捕获异常信息后Spring事务失效处理方法](https://blog.csdn.net/qq_41107231/article/details/106698940)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文