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!");
}
}