zoukankan      html  css  js  c++  java
  • AOP 注入失败的问题

    启用了AOP 后,报这样的类似错误: 

    Error creating bean with name 'bpmpSysUserService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.bkc.bpmp.core.dao.BaseDao com.bkc.bpmp.core.service.BaseService.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bpmpSysUserMapper': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy24]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy24

    (注:个人猜测,可能不正确)

    1、其他的配置都如同网上相关的AOP 一般,这里不详写了,框架采用 SpringMVC+Spring+Mybatis

    2、我这里的实际情况是 没有写 接口,写了一个BaseDao,BaseService 之类的,然后直接采用继承父类来实现,然后就报 上述的错误

      解决方法:这个配置写成这样 <aop:aspectj-autoproxy proxy-target-class="false"/> ,由于没有使用接口,AOP 代理采用 CGLIB, 需要在子类中都添加 默认的构造方法(理由不知)

    3、我之前使用AOP 也出现过 注入失败的情况,采用一个接口、一个接口实现类,此时AOP 自动使用的代理是JDK

      解决方法:接口和接口实现类 命名需要区分,且 在注入的时候采用 接口 来创建对象

      

  • 相关阅读:
    socket阻塞与非阻塞,同步与异步
    Python列表切成多个/生成多个空列表
    virtualbox 下windows与虚拟机实现文件共享---挂载
    centos安装mysql
    centos安装Python2.7
    在遍历或者迭代过程中对集合进行增删 都会发生异常(迭代器的并发异常)
    List
    LinkedList
    增强for循环
    Collection中的迭代器
  • 原文地址:https://www.cnblogs.com/panie2015/p/5984733.html
Copyright © 2011-2022 走看看