1
当我的系统抛出一个异常时,应该调用下面的方法,但事实并非如此。它只有当我删除注释的 '投掷' 和 '例外' 作为参数的工作原理:Spring AOP - @AfterThrowing
不起作用:
@AfterThrowing(pointcut="execution(public * br.com.ogfi.*.controller.*.*(..))", throwing="e")
public void afterThrowing(Exception e) {
System.out.println("Test");
}
作品:
@AfterThrowing(pointcut="execution(public * br.com.ogfi.*.controller.*.*(..))")
public void afterThrowing() {
System.out.println("Test");
}
有谁知道我做错了什么?
这是整个类:
package br.com.ogfi.portalbackoffice.aspect;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class AfterThrowAdvice {
@AfterThrowing(pointcut="execution(public * br.com.ogfi.*.controller.*.*(..))", throwing="e")
public void afterThrowing(Exception e) {
System.out.println("Boo! We want our money back!");
//ex.printStackTrace();
//System.out.println("Boo! We want our money back!");
}
}