spring 事务注解 需要捕获的throw new Exception("...");不会回滚

@Transactional(rollbackFor=class) 
    public void methodName() {
       
       // 会回滚
       throw new Exception("...");
       // 会回滚
       throw new RuntimeException("...");

rollbackFor 默认就是 RuntimeException
@Transactional(rollbackFor=class) 或者是 @Transactional()

public ItimDaoImpl getItemDaoImpl() {
       // 不会回滚
       throw new Exception("...");

// 会回滚  
      throw new RuntimeException("");   
  }    
posted on 2017-03-10 15:13  张洪波IDEA  阅读(500)  评论(0编辑  收藏  举报