java.lang.ClassCastException: $Proxy 9 cannot is cast to TEST.SPRING.SERVICE.IMPL.PERSONSERVICEIMPL2 at Test.junit. Testpersonservice.test (Testpersonservice.java: -) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Nativemethodaccessorimpl.java: the) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java: -) at Java.lang.reflect.Method.invoke (Method.java:597) at org.junit.runners.model.frameworkmethod$1. Runreflectivecall (Frameworkmethod.java: -) at Org.junit.Internal. Runners.model.ReflectiveCallable.run (Reflectivecallable.java: the) at org.junit.runners.model.FrameworkMethod.invokeExplosively (Frameworkmethod.java: A) at Org.junit.Internal. Runners.statements.InvokeMethod.evaluate (Invokemethod.java: -) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (Blockjunit4classrunner.java: -) at Org.junit.runners.BlockJUnit4ClassRunner.runChild (Blockjunit4classrunner.java: in) at Org.junit.runners.BlockJUnit4ClassRunner.runChild (Blockjunit4classrunner.java: the) at org.junit.runners.parentrunner$3. Run (Parentrunner.java:193) at org.junit.runners.parentrunner$1. Schedule (Parentrunner.java: the) at Org.junit.runners.ParentRunner.runChildren (Parentrunner.java:191) at org.junit.runners.parentrunner.access$ the(Parentrunner.java: the) 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: -) at ORG.ECLIPSE.JDT.Internal. Junit.runner.TestExecution.run (Testexecution.java: -) 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)
Java code
public void Test () {
ApplicationContext CTX = new Classpathxmlapplicationcontext ("Beans.xml");
System.out.println (Ctx.getbean ("Personserviceimpl"));
Personservice Personservice = (personservice) ctx.getbean ("PersonServiceImpl2");
Personservice.sava ("Sophia");
}
AoP is interface-oriented, so you want to transform the interface
Spring: $Proxy 9 cannot is cast to TEST.SPRING.SERVICE.IMPL.PERSONSERVICEIMPL2