No transaction aspect-managed TransactionStatus in scope

   org.springframework.transaction.NoTransactionException: No transaction aspect-managed TransactionStatus in scope

出错

    @Async
public Future<Boolean> test(){
return delete();
}
@Transactional(rollbackFor = Exception.class)
public Future<Boolean> delete(){
jdbcTemplate.update("delete from tb_name");
jdbcTemplate.update("delete from tb_age");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new AsyncResult<>(true);
}

改成

    // 放一起
@Async
@Transactional(rollbackFor = Exception.class)
public Future<Boolean> test(){
return delete();
}
public Future<Boolean> delete(){
jdbcTemplate.update("delete from tb_name");
jdbcTemplate.update("delete from tb_age");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new AsyncResult<>(true);
}

No transaction aspect-managed TransactionStatus in scope

原文:https://www.cnblogs.com/freeatalk/p/15311756.html

以上是No transaction aspect-managed TransactionStatus in scope的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>