【发布时间】:2020-11-10 07:50:04
【问题描述】:
我是 Spring AOP 的新手。我尝试为 ResponseEntityExceptionHandler.handleException 方法编写建议以记录异常信息。在寻找解决方案数小时后,我陷入了困境。
这是我的 Apect 组件
@Log4j2
@Aspect
@Component
public class LogginAspect {
@Pointcut(value = "execution(* org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler.handleException(..)) && args(ex, request)")
public void callSpringExceptionHandler() {}
@Before("callSpringExceptionHandler()")
public void logBeforeError(JoinPoint joinPoint, Exception ex, WebRequest request) {
log.error(ex.getMessage(), ex);
}
}
我尝试了不同的切入点模式,但没有成功。 我的建议 logBeforeError 根本没有调用过。请帮我解决我的问题
【问题讨论】:
标签: spring spring-mvc spring-aop