内部服务将交易标记为“仅回滚”

时间:2019-02-12 21:05:49

标签: spring spring-transactions rollback

使用Spring并遇到下一种情况:

public class Service1{

  @Autowired
  Service2 service2;

  @Transactional(noRollBackFor = MyException.class)
  public void service1(){        
    service2.service2();
  }

}


public class Service2{

  @Transactional
  public void service2(){      
    throw new MyException();
  }

}

为什么在调用service2.service2()时将事务标记为“ rollbackonly”?我不明白,因为这两种事务方法共享同一事务,并且该事务被标记为“ noRollBackFor = MyException.class”

谢谢

0 个答案:

没有答案