1.4.3 启用事务

1 模块内启用事务

在java代码中访问的资源在同一模块内,使用 Spring 提供的声明式事务管理,实现模块内启用事务。

  • 在请求定义中设置启用事务,服务编译时,会在controller的方法前,增加 @Transactional 注解,从而实现事务管理。

2 跨模块启用事务

在java代码中访问的资源不在同一模块内,使用系统提供的分布式事务管理,实现跨模块启用事务。

  • 添加com.justep/tools/1.0.0依赖
  • 引入 import com.justep.util.db.GlobalTransactional
  • 在方法前面添加注解 @GlobalTransactional,实现分布式事务

results matching ""

    No results matching ""

    results matching ""

      No results matching ""