日期:2014-05-17  浏览次数:20919 次

Spring注入出错,麻烦各位大侠解决下(Caused by: java.lang.IllegalArgumentException:Can not set )


框架是spring3.0MVC+Hibernate,在启动项目的时候,会报如下的错误:



严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: BIA.Service.LoginServiceImp BIA.Controller.LoginController.loginServiceImp; nested exception is java.lang.IllegalArgumentException: Can not set BIA.Service.LoginServiceImp field BIA.Controller.LoginController.loginServiceImp to $Proxy20
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: BIA.Service.LoginServiceImp BIA.Controller.LoginController.loginServiceImp; nested exception is java.lang.IllegalArgumentException: Can not set BIA.Service.LoginServiceImp field BIA.Controller.LoginController.loginServiceImp to $Proxy20
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 42 more
Caused by: java.lang.IllegalArgumentException: Can not set BIA.Service.LoginServiceImp field BIA.Controller.LoginController.loginServiceImp to $Proxy20
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:657)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:498)
... 44 more
2014-4-30 14:20:03 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /BIAoa threw load() exception
java.lang.IllegalArgumentException: Can not set BIA.Service.LoginServiceImp field BIA.Controller.LoginController.loginServiceImp to $Proxy20
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:657)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor