项目场景:
提示:这里简述项目相关背景:
执行某个方法 抛出异常后 不打印异常信息 全局异常也未捕获到
问题描述
提示:这里描述项目中遇到的问题:
写了一个全局 切面 注解
@Slf4j
@Aspect
@Component
public class PreventReplayAspect {
private static final String point_cut = "execution(* com.mkx.cn..*Controller.save*(..))"
+"||execution(* com.mkx.cn..*Controller.add*(..))"
+ "||execution(* com.mkx.cn..*Controller.update*(..))"
+ "||execution(* com.mkx.cn..*Controller.edit*(..))";
@Around(point_cut)
public Object interceptor(ProceedingJoinPoint p) throws Throwable {
。。。。。。。。。。省略代码。。。。。。。。
try {
return p.proceed();
} catch (Exception e) {
//确保方法执行异常时,释放限时标记
redisTemplate.delete(redisCacheKey);
}
return null;
}
}
解决方案:
提示:这里填写该问题的具体解决方案:
try {
return p.proceed();
} catch (Exception e) {
//确保方法执行异常时,释放限时标记
redisTemplate.delete(redisCacheKey);
}
改成--------------》
return p.proceed();
把上面的try catch去掉完美解决 因为异常被捕获了 没有抛出去 所以全局的异常处理器 也捕获不到异常 造成 不打印异常的假象