Spring 使用AOP导致IOC注入失败

前几天把权限系统重构了,服务层针对前后台分别提供相应的接口,但在配置注入的时候出现如下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysCurrentSessionService' defined in ServletContext resource [/WEB-INF/servicecontext/sysUserContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1 implementing com.centerm.service.rightmanage.ISysUserService,com.centerm.service.rightmanage.ISysUser4Dwr,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.centerm.service.rightmanage.Impl.SysUserService] for property 'sysUserService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1 implementing com.centerm.service.rightmanage.ISysUserService,com.centerm.service.rightmanage.ISysUser4Dwr,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.centerm.service.rightmanage.Impl.SysUserService] for property 'sysUserService': no matching editors or conversion strategy found

上面的英文意思说无法将一个实现com.centerm.service.rightmanage.ISysUserService,com.centerm.service.rightmanage.ISysUser4Dwr,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised接口的代理注入给com.centerm.service.rightmanage.Impl.SysUserService

 

之所以会出现这个问题是:因为我配置了aop拦截了sysUserService对象,Spring依照sysUserService对象生成其接口的代理,当把这接口的代理塞给sysUserService对象出错了

简化下如下:

MyBean implements IBean

ProxyBean implements IBean

myBean=ProxyBean 当然会出错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值