java.lang.ClassCastException: com.service.impl.OrderPlanServiceImpl cannot be cast to com.provider.service.IUserInfoService
at com.easylabplus.provider.test.UserInfoTest.testUserInfoService(UserInfoTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.InvokeMethod.evaluate(InvokeMethod.java:20)
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)

问题提示没有在第二个类当中找到你注册的Service名字

原因是我的测试类中没有写好Service对应的映射名字

 @Test
public void testUserInfoService() throws Exception {
ClassPathXmlApplicationContext aContext = new ClassPathXmlApplicationContext(
"applicationContext.xml");
//问题就是下边这个userInfoService的名字写错了
IUserInfoService userInfoService = (IUserInfoService) aContext
.getBean("userInfoService");
List<UserInfo> list = userInfoService.queryAll();
Gson g = new Gson();
System.out.println(g.toJson(list)); }

cannot be cast to的更多相关文章

  1. C++ cast

    excerpted from Type conversions K&R Section 2.7 p59 对type conversion 的解释: The precise meaning of ...

  2. Java-Spring:java.lang.ClassCastException: com.sun.proxy.$Proxy* cannot be cast to***问题解决方案

    java.lang.ClassCastException: com.sun.proxy.$Proxy* cannot be cast to***问题解决方案 临床表现: 病例: 定义代理类: @Tra ...

  3. SSH整合时执行hibernate查询报错:java.lang.ClassCastException: com.ch.hibernate.Department_$$_javassist_0 cannot be cast to javassist.util.proxy

    今天在整合ssh三个框架时,有一个功能,是查询所有员工信息,且员工表和部门表是多对一的映射关系,代码能正常运行到查询得到一个List集合,但在页面展示的时候,就报异常了, java.lang.Clas ...

  4. CAST function should support INT synonym for SIGNED. i.e. CAST(y AS INT)

      Login / Register Developer Zone Bugs Home Report a bug Statistics Advanced search Saved searches T ...

  5. Java Class.cast方法

    1.Java api public T cast(Object obj); Casts an object to the class or interface represented 解释的比较笼统, ...

  6. SELECT CAST(GETDATE() AS VARCHAR(10)) 显示不同格式的原因

    开发人员测试时,发现生产服务器与测试服务器执行SELECT CAST(GETDATE() AS VARCHAR(10))语句显示的格式不一样.如下所示 Server A Server B 其实出现这个 ...

  7. 【MySQL】使用Length和Cast函数计算TEXT类型字段的长度

    背景: 前段时间,业务需要,为了快速让解析的Excel入库,所以把不是很确定的字段全部设置成了TEXT. 今天需要进行表结构优化,把字段长度控制在合适的范围,并尽量不使用TEXT类型. -- 计算长度 ...

  8. sql 中convert和cast区别

    SQL中的cast和convert的用法和区别 更多 来源:SQL学习浏览量: 学习标签: cast convert sql 本文导读:SQL中的cast 和convert都是用来将一种数据类型的表达 ...

  9. postgres 类型转换 cast 转

    转自: http://blog.csdn.net/yufenghyc/article/details/45869509 --1 例子postgres=# select 1/4; ?column? -- ...

  10. 错误 java.lang.ClassCastException: com.ylpw.sms.YZZYSenderUtil cannot be cast to ResourceBundle

    出现错误: java.lang.ClassCastException: com.ylpw.sms.YZZYSenderUtil cannot be cast to ResourceBundle 百度搜 ...

随机推荐

  1. 写写Django中DRF框架概述以及序列化器对象serializer的构造方法以及使用

    写写Django中DRF框架概述以及序列化器对象serializer的构造方法以及使用 一.了解什么是DRF DRF: Django REST framework Django REST framew ...

  2. load/domContentLoaded事件、异步/延迟Js 与DOM解析

    一.DOMContentLoaded 与 load事件 关于load和DOMContentLoaded事件,mdn对于它们是这样描述的: DOMContentLoaded mdn文档地址:https: ...

  3. 【linux】文件目录说明

    /根目录.一般不含任何文件,除了可能的标准的系统引导映象,通常叫/vmlinuz .所有其他文件在根文件系统的子目录中. /bin 一般用户使用的命令 /boot 放置内核及LILO.GRUB等导引程 ...

  4. CentOS 6 & 7 忘记root密码的修改方法

    https://www.linuxidc.com/Linux/2018-01/150211.htm

  5. Conv

    folly/Conv.h folly/Conv.h is a one-stop-shop for converting values across types. Its main features a ...

  6. django-聚合操作

    聚合操作就是对数据库的数值类型操作的方法 avg,sum,max,min,count select avg(age) from students  # 求年龄平均值  django中的聚合操作 1.a ...

  7. angularjs中的$http详解

    语法: 要将区别先弄清$http服务,它是对原生XMLHttpRequest对象的简单封装,是只能接受一个参数的方法, 这个方法会返回一个promise对象,具有sccess和error两个方法.当然 ...

  8. ffmpeg默认输出中文为 UTF-8

    在使用ffmpeg 进行对音视频文件解码输出信息的时候会出现乱码. 从网上找到了说ffmpeg默认格式 为 utf-8 如果vs工程使用的的 Unicode 则需要将 utf-8转 Unicode 才 ...

  9. openAL在mac下播放音源结束时判断处理

    音频播放完毕,自然停止 alGetSourcei(source[0], AL_BUFFERS_QUEUED, &state);    NSLog(@"queued number:%d ...

  10. Angular2中Input和Output

    @Input @Input是用来定义模块的输入的,用来让父模块往子模块传递内容: @Output 子模块自定义一些event传递给父模块用@Output. 对于angular2中的Input和Outp ...