• 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,一定得仔细!


  • 相关阅读:
    null和undefined的区别
    减少页面加载时间的方法
    html5有哪些新特性、移除了那些元素?
    cookies,sessionStorage 和 localStorage 的区别
    小程序页面
    快速保存网页图片的工具
    Flex 布局教程
    第一阶段:Python开发基础 day08 Python基础语法入门--列表元组字典集合类型的内置方法
    第一阶段:Python开发基础 day08 数据类型的内置方法 课后作业
    python学习第一周知识内容回顾与小结
  • 原文地址:https://www.cnblogs.com/a1111/p/12816173.html
Copyright © 2020-2023  润新知