yypz

异常如下:

     [com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor]-[ERROR] $Proxy5 cannot be cast to               com.student.service.StudentService

java.lang.ClassCastException: $Proxy5 cannot be cast to com.student.service.StudentService


解决方法:

 导致出问题的代码片段:

StudentService studentService= (StudentService) BeanFactory.getBean("studentService");

              应该改为Service Service= (Service) BeanFactory.getBean("studentService");

                     其中StudentService 实现了Service接口

这主要代理需要用到接口


             Ps: 所以通过这种代理的话,必须声明一个接口(例如Service),并在接口中声明实现类(例如:StudentService)所需要的方法,这样 Service Service= (Service) BeanFactory.getBean("studentService");  中,service来调用StudentService 实现的方法。


分类:

技术点:

相关文章:

  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2021-10-20
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案