zoukankan      html  css  js  c++  java
  • ssh报错java.lang.ClassCastException: com.sun.proxy.$Proxy6 cannot be cast to org.service.impl.EmpServi

    错误如下:

    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;
    	
    	@Before
    	public void init(){
    		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    		empService = (EmpServiceImpl)applicationContext.getBean("empService");
    	}

    改为:

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

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


  • 相关阅读:
    什么是 HTTPS
    首页飘雪的效果
    load data导入数据之csv的用法
    phpcms v9 配置sphinx全文索引教程
    js的一些技巧总结
    MySQL 清除表空间碎片
    使用的前台开发在线工具
    (phpQuery)对网站产品信息采集代码的优化
    永远不要打探别人工资
    git 显示多个url地址推送
  • 原文地址:https://www.cnblogs.com/a1111/p/12816173.html
Copyright © 2011-2022 走看看