spring boot transaction manager advice to roll back all exceptions

只愿长相守 提交于 2019-12-07 03:42:28

Use custom annotations

If you find you are repeatedly using the same attributes with @Transactional on many different methods, then Spring's meta-annotation support allows you to define custom shortcut annotations for your specific use cases. For example, defining the following annotations

  @Target({ElementType.METHOD, ElementType.TYPE})
  @Retention(RetentionPolicy.RUNTIME)
  @Transactional(rollbackFor=Exception.class)
  public @interface OrderTx {
  }

https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#tx-custom-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!