cannot be cast to
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)); }
最新文章
- mysql-批量修改表字段中的某一部分内容
- 【CentOS】ifconfig命令 :command not found &; yum命令 :cannot find a valid baserl for repo: base/7/x86_64
- C#中常用的转义字符及@符号的一些作用
- HttpRequest重写,解决资源战胜/链接超时/分块下载事件通知 问题。
- App开发
- Hive分布式的数据仓库
- linux编辑器 vi的使用
- ssh无密登录
- keepalive的 nopreempt 非抢占
- js 实现div模块的截图并下载功能(可制作长图)
- 单点登录实现机制:桌面sso
- Python 3 利用 Dlib 19.7 实现摄像头人脸识别
- java 23种设计模式教程
- 解决linux root 认证失败的问题
- java集合框架(1) hashMap 简单使用以及深度分析(转)
- chrome 插件 导出与导入,以apizza SQ为例
- glide 解决 golang.org/x/net 等依赖包无法获取
- Git_创建版本库
- poj3107 Godfather 求树的重心
- excel宏调用webservice使用存储过程同步excel数据的方法