- 如果连接点的方法在执行过程中抛出异常,则会触发 AfterThrowing 通知,而想要获取该异常的相关信息,需要在 AfterThrowing 通知中,加入 throwing 属性
@AfterThrowing(value = "pointCut()", throwing = "e")
public void throwAdvice(Exception e) {
System.out.println("throw advice...");
}
注意:1.只有 AfterThrowing 通知有 throwing 属性,2.需要指定接收异常的参数e,需要和通知方法参数一致