spring aop 内部调用问题解决

基于 proxy 的 spring aop 带来的内部调用问题可以使用 AopContext.currentProxy() 强转为当前的再调用就可以解决了

例如:
文中的
public Account getAccountByName2(String userName) {
return this.getAccountByName(userName);
}
修改为public Account getAccountByName2(String userName) {
return ((AccountService)AopContext.currentProxy()).getAccountByName(userName);
}

猜你喜欢

转载自www.cnblogs.com/wulm/p/9486531.html
今日推荐