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"/>
原文地址:https://www.cnblogs.com/wujixing/p/5757662.html