//默认spring只能在捕获到runtimeException时才会回滚,

 

throw new RuntimeException("出现runtime异常");

} catch (BadPaddingException bpe) {
     
} catch (Exception e) {
     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();      
}

 

//如果try catch 到Exception级别 只能设置手动回滚。

throw new RuntimeException("出现runtime异常");

} catch (BadPaddingException bpe) {
     
}

这样也会自动回滚。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-02-09
  • 2021-07-12
  • 2021-05-25
  • 2022-02-20
  • 2021-08-11
猜你喜欢
  • 2021-07-14
  • 2018-05-24
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案