一、情形还原。
@Transactional(rollbackFor=Exception.class)
public void method(){
// 会回滚
throw new Exception("");
// 会回滚
throw new RuntimeException("");
}
@Transactional(rollbackFor=RuntimeException.class) 或者 @Transaction()
public void method(){
// 不会回滚
throw new Exception("");
// 会回滚
throw new RuntimeException("");
}
二、原因。
rollbackFor 默认是 RuntimeException,手动抛出 Exception 则无法回滚