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

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

      

  • 相关阅读:
    Java——GUI
    linux变量
    shell脚本
    linux查找文件命令
    composer的安装
    restful的nginx配置方法
    api调用安全
    PHP设置Cookie的HTTPONLY属性
    php的异常处理
    php错误报告
  • 原文地址:https://www.cnblogs.com/panie2015/p/5984733.html
Copyright © 2011-2022 走看看