zoukankan      html  css  js  c++  java
  • java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to com.bjsxt.service.UserServiceImpl01_AOP.

    对于Spring AOP 采用两种代理方法,一种是常规JDK,一种是CGLIB,我的UserDao了一个接口IUserDao,当代理对象实现了至少一个接口时,默认使用 JDK动态创建代理对象,当代理对象没有实现任何接口时,就会使用CGLIB方法。点此查看详细介绍>>>
    治疗方法
    如果你的代理对象没有实现接口的方法,就将代理对象转换成接口。
    获取代理类的代码该为:

    vate ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
    IUserService iuserService=(IUserService)ac.getBean("userService"); 
    

     或者在applicationcontext.xml里加上这一句

    <aop:aspectj-autoproxy proxy-target-class="true"/>
    
  • 相关阅读:
    BM&EXCRT
    杨丰磊
    poj3613 Cow Relays
    详解KMP算法
    信息学作文
    恐怖的奴隶主(bob)
    玩具(toy)
    杯子 (glass)
    P3916 图的遍历
    《上帝给我一个任务,叫我牵一只蜗牛去散步》
  • 原文地址:https://www.cnblogs.com/wujixing/p/5757662.html
Copyright © 2011-2022 走看看