错误如下:

java.lang.ClassCastException: com.sun.proxy.$Proxy6 cannot be cast to org.service.impl.EmpServiceImpl

at org.service.impl.EmpServiceImplTest.init(EmpServiceImplTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

相关代码如下:

private IEmpService empService;@Beforepublic void init(){ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");empService = (EmpServiceImpl)applicationContext.getBean("empService");}

改为:

private IEmpService empService;@Beforepublic void init(){ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");empService = (IEmpService)applicationContext.getBean("empService");}

简单的来说是将   EmpServiceImpl 改为IEmpService就OK,一定得仔细!

ssh报错java.lang.ClassCastException: com.sun.proxy.$Proxy6 cannot be cast to org.service.impl.EmpServi相关推荐

  1. Ebean报错java.lang.ClassCastException: com.project.model.xxx cannot be cast to com.project.model.xxx

    使用Ebean查询数据库时报错: 接口接收前端传过来的id代码: 报错内容: com.project.model.NavManage cannot be cast to com.project.mod ...

  2. spring的动态代理,碰到了一个类型转换的问题:java.lang.ClassCastException: com.sun.proxy.$Proxy16 cannot be cast to com.

    spring的动态代理,碰到了一个类型转换的问题: java.lang.ClassCastException: com.sun.proxy.$Proxy16 cannot be cast to com ...

  3. java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to...异常

    java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to...异常 参考文章: (1)java.lang.ClassC ...

  4. 报错java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String解决踩坑

    java.lang.ClassCaption: java.lang.Long cannot be cast to java.lang.String 问题背景 service传参调用mapper,报错: ...

  5. mybatisplus实体类映射报错: java.lang.ClassCastException: User cannot be cast to UserVo

    目录 问题现象: 问题分析: 下面的情况则更加复杂: 解决方法: 问题现象: 今天在使用springboot+mybatisplus做项目的时候,设置完mapper.xml文件之后发生了以下异常:   ...

  6. 报错java.lang.ClassCastException: XXXXXXX.Application cannot be cast to android.app.MyApplicati

    最近做百度地图,发现这种错误一般是AndroidManifest.xml中配置有错. <application     android:icon="@drawable/icon&quo ...

  7. ssh根据姓名查询的时候报错java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!

    错误如下: java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! at org.hibe ...

  8. ssh根据姓名查询的时候报错java.lang.IndexOutOfBoundsException: Remember that

    错误如下: java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! at org.hibe ...

  9. 解决Tomcat下IntelliJ IDEA报错java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener

    解决Tomcat下IntelliJ IDEA报错java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener   笔者在做代 ...

最新文章

  1. 被swoole坑哭的PHP程序员
  2. 《梦断代码Dreaming In Code》阅读计划
  3. mybatis添加记录时返回主键id
  4. 二十、预处理CSS的LESS
  5. SimpleJdbcInsert 和SimpleJdbcCall
  6. git如何切换分支_如何让 Jenkins 支持选择 git 分支进行构建
  7. Mac openCV环境搭建
  8. 深度拷贝时,类中的非简单类型字段
  9. php表达式求值,PHP实现基于栈的后缀表达式求值功能
  10. (13.3)Latex参考文献引用及常规引用
  11. 问题 C: 所罗门王的宝藏
  12. unity 引用 移动mm 支付sdk
  13. mysql 提取字符串首字母_SQL获取字段字符串中文首字母
  14. 操作系统PV大题_小和尚老和尚喝水问题
  15. python绘制樱花洒落_Python:绘制樱花树
  16. 郭台铭资产对比马云谁更有钱?两人身价多少亿
  17. 博客书写-教师节收益
  18. hadoop权威指南(一)
  19. vc中添加asm文件
  20. vivo老照片修复解密

热门文章

  1. iis php打开空白页,windows+IIS+php 访问显示空白页 php版本信息访问正常
  2. 无法载入增效工具_山东省 智能工具箱 智能工具管理 工具管理企业数字化管理...
  3. B Convex Polygon
  4. AreYouBusy
  5. 2021牛客OI赛前集训营-交替【生成函数】
  6. P4180-[BJWC2010]严格次小生成树【Kruskal,倍增】
  7. YbtOJ#943-平方约数【莫比乌斯反演,平衡规划】
  8. P6835-[Cnoi2020]线形生物【期望dp】
  9. CF297E-Mystic Carvings【树状数组】
  10. P4310-绝世好题【位运算,dp】