在做spring的前置通知时报错:
java.lang.ClassCastException: class com.sun.proxy.$Proxy5 cannot be cast to class org.wpc.iml.StudentServiceIml
错误原因是:
接收类型写为接口的实现类,如以下代码所示:
StudentServiceIml studentService = (StudentServiceIml)applicationContext.getBean("studentService");
将代码修改为:
IStudentService studentService = (IStudentService)applicationContext.getBean("studentService");
用接口进行接收。