spring aop 无法代理父类方法 的解决方法
2016-08-10 17:38
1571 查看
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
首先是父类
cn.geektom.service.A
内部有个方法:method();
然后是子类
cn.geektom.service.B extends A
现在要对B类中的method() 进行aop代理。
如果按照如下配置
<aop:config> <aop:advisor advice-ref="a" pointcut="execution(* cn.geektom.service.B.method(..))" order="30" /> </aop:config>
是无法做到代理的。spring aop 只会在B中寻找method()方法,而父类A的method()方法则会被忽略掉。所以必须修改一下
<aop:config> <aop:advisor advice-ref="a" pointcut="execution(* cn.geektom.service.A.method(..)) and target(cn.geektom.service.B)" order="30" /> </aop:config>
代理的方法是A中的method,但是目标类必须是B,如果没有添加后面的target,那么任何A的子类调用method()方法时都会被代理。
相关文章推荐
- spring AOP中自身方法调用无法应用代理解决办法
- spring aop代理不了父类,会忽略从父类继承的方法。
- Spring AOP中让spring也能代理父类的方法
- springAOP——代理对象的产生及方法调用
- 关于Hibernate在反向工程时无法选择Spring DAO Type的解决方法【更新版】
- Spring自动扫描无法扫描jar包中bean的解决方法(转)
- SQL Server代理服务无法启动的解决方法
- Spring.net 间接调用被AOP拦截的方法失效(无法进入aop的拦截方法)
- springcloud使用feign实现服务间条用,参数数据太大,无法调用成功解决方法
- hibernate+spring 连接无法自动关闭解决方法
- [ISA]QQ通过ISA2006代理登陆无法接收发送文件和图片表情的解决方法
- Spring aop事务代理对象通过TransactionInterceptor处理目标方法事务过程,cglib方式
- Spring Cloud 监控服务器下 IP/URL 不正确导致无法注册的解决方法
- Spring配置文件使用@Value注解注入值的方法,以及AOP切面在Spring+SpringMVC中的不生效解决
- Spring AOP无法拦截内部方法调用
- MyEclipse2013 Hibernate反向工程步骤及DAO Type无法选择Spring DAO解决方法
- 利用Spring AOP中的引入解决java无法多继承问题
- Chrome设置本地代理无法访问localhost的解决方法
- 关于spring aop代理不到父接口中的方法
- Chrome设置本地代理无法访问localhost的解决方法(转)