今天开发过程当中突然遇到了一个问题
Exception in
thread "main" java.lang.ClassCastException: $Proxy5 cannot be cast
to com.hanqing.service.imp.EmployeeServiceImp
at
com.hanqing.test.Test.main(Test.java:17)
仔细看来原来是测试方法写错了
ApplicationContext ac=new
ClassPathXmlApplicationC ontext("applicationContext.xml");
EmployeeServiceImp esi=(EmployeeServiceImp)ac.getBean("employeeServiceImp");
Employee e=new Employee("shufeng",
"wehanqing@126.com", new Date(), 12312f);
esi.addEmployee(e);
写成了方法的具体实现类了,改成接口的形式即可