@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.
数据没回滚。
你这个可能是由于数据库连接超时引起的