这是我的代码
@Around("service()")
public Object serviceThreadLocalHandle(ProceedingJoinPoint joinPoint) throws Throwable{
// joinPoint is a service instance
Object proceed = joinPoint.proceed();
cache = ContractCache.LOCAL_CACHE.get();
// there i throw a exception but i can not rollback the transaction
if(true){
throw new RuntimeException();
}
return proceed;
}
那么如何在我的方面Spring Boot 1.5.8 RELEASE上回滚事务?
答案 0 :(得分:0)
您可以在@Transactional批注中声明要在引发RuntimeException时执行回滚: @Transactional(rollbackFor = RuntimeException.class)