org.springframework.transaction.UnexpectedRollbackException: JTA transaction already rolled back (probably due to a timeout)

错误原因默认的Spring 默认的事务是 tomeout 是 -1

org.springframework.transaction.UnexpectedRollbackException: JTA transaction already rolled back (pr

原因是 这里使用Spring 默认事务

java int timeout() default -1;

sql 查询时间长 再加上入库时间 超出了默认的时间范围

所以抛出了 UnexpectedRollbackException 异常
打印 JTA transaction already rolled back (probably due to a timeout) 错误

解决办法:

  • 设置超时间时间 长点
    java @Transactional(rollbackFor = Exception.class,timeout = 60)
  • 将插入语句分离出去,将事务加到插入语句中
  • 优化sql 减少查询时间

相关文章:

  • 2021-07-27
  • 2021-04-13
  • 2021-04-27
  • 2022-12-23
  • 2021-07-04
  • 2021-11-21
猜你喜欢
  • 2021-10-29
  • 2022-12-23
  • 2021-12-31
  • 2021-06-11
  • 2021-11-29
  • 2021-12-20
相关资源
相似解决方案