1.首先需要在代码中注入事务管理器

@Autowired private PlatformTransactionManager transactionManager;


2.代码中使用如下

public
void dealResult(Map<String,List<WKOrder>> resultMap){ TransactionTemplate template = new TransactionTemplate(transactionManager); template.execute(new TransactionCallbackWithoutResult(){ @Override protected void doInTransactionWithoutResult(TransactionStatus arg0) { //TODO:实现你的业务逻辑 }}); }

3.好处

可以实现定制化的事务管理,而不必局限于外部对接口的控制。比如给一个私有方法添加事物等。

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2021-10-04
  • 2022-12-23
  • 2021-09-27
  • 2021-04-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-25
  • 2021-05-21
  • 2022-12-23
  • 2022-01-01
  • 2021-12-15
相关资源
相似解决方案