spring boot @Transactional注解的方法执行时间长最后连接被回收没回滚正常吗?

    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void test() {
        try {
            //这里比较耗时,大概6分钟
        } catch (Exception e) {
            LOG.error("这里没有打印错误日志,说明没遇到异常");
            throw new DataAccessException();
        }
    }

现在打印了错误日志

Caused by: org.springframework.transaction.TransactionSystemException: Could not commit JDBC transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.

数据没回滚。

阅读 2.3k
1 个回答

你这个可能是由于数据库连接超时引起的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题