定义
@Before声明一个方法为后置异常通知。
参数
value
String value();
可以为切入点表达式,也可以为使用了@PointCut被声明为切入点的方法。
pointcut
String pointcut() default "";
同value,在两者间选择一个使用。
throwing
String throwing() default "";
后置异常通知中用于获取异常的参数名。
示例
Link to original ```java @Aspect @Component @Slf4j public class LogAspect { @PointCut("@annotation(com.example.annotation.Log)") public void logAnnotation() { } @AfterThrowing(pointcut = "logAnnotation()", throwing = "exception") public void logAfterThrowing(JoinPoint joinPoint,Throwable exception) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); log.info(“after method:{} failed:{}”, method.getName(), exception.getMessage()); } }