由於spring中的aop攔截的是代理對象
當攔截的目標方法被本類的另一個方法調用時,會出現攔截失效
最佳實踐:
例如攔截RegulationService的update(regulation)方法,當RegulationService的add方法(當前類的非update方法)調用update方法時,為了依然能攔截到
update方法
可使用如下方式獲取當前代理對象
public int add(...){
Regulation result = ((RegulationService)(AopContext.currentProxy())).update(regulation);// 獲取當前代理
......
}