uppose療法是A類:SpringAOP複雜的切入點
public class A {
public B b;
public void justDoIt1(){
b.getB();
}
@SomeAnnotation
public void justDoIt2(){
b.getB();
}
}
和B類:
public class B{
public void getB(){
System.out.println("get");
}
}
我們如何創建切入點B.getB(執行),其是從內部被稱爲方法用@SomeAnnotation註釋?
這裏是我試過
@Aspect
public class LocalizationAspect {
@Before(value = "@within(Localize) && execution(* B.getB())")
public void aspectStuff() {
System.out.println("aspect");
}
}
只是爲了讓我的觀點明確:調用justDoIt2()時,預期產出將是;
方面 得到
但調用justDoIt1時();
得到
注:我使用SpringAOP(也許它有一些這方面的限制) 任何幫助?
您的類是否實現了包含建議方法的接口? (默認情況下,Spring AOP使用JDK代理) –