【异常篇-spring】org.springframework.beans.factory.BeanNotOfRequiredTypeException
2018-03-01 13:59
627 查看
报错异常:
2018-03-01 13:44:18.091 [localhost-startStop-1] ERROR o.a.c.c.C.[.[.[/zsedu-score-query-webserver-webapp] -- StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scoreQueryController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' must be of type [com.nenglong.rrt.webserver.service.exam.StudentService], but was actually of type [com.nenglong.rrt.webserver.service.user.impl.StudentServiceImpl$$EnhancerBySpringCGLIB$$9f0ce91f]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(Common...............................
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' must be of type [com.xxx.webserver.service.exam.StudentService], but was actually of type [com.xxx.webserver.service.user.impl.StudentServiceImpl$$EnhancerBySpringCGLIB$$9f0ce91f]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:364)
..............................
解决方法:@Resource
private StudentService<Student, StudentForm> studentService;改为@Resource(name="studentService2")
private StudentService<Student, StudentForm> studentService;原理:默认按照名称进行装配,名称可以通过name属性进行指定,如果没有指定name属性,当注解写在字段上时,默认取字段名进行按照名称查找。com.xxx.webserver.service.user包下也有一个studentService接口,取bean时未指定名称导致到的..service.user包下的接口类型不匹配。
备注:...user包下的studentService实现类代码@Service("studentService")
public class StudentServiceImpl implements studentService
{
.......
}
2018-03-01 13:44:18.091 [localhost-startStop-1] ERROR o.a.c.c.C.[.[.[/zsedu-score-query-webserver-webapp] -- StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scoreQueryController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' must be of type [com.nenglong.rrt.webserver.service.exam.StudentService], but was actually of type [com.nenglong.rrt.webserver.service.user.impl.StudentServiceImpl$$EnhancerBySpringCGLIB$$9f0ce91f]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(Common...............................
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' must be of type [com.xxx.webserver.service.exam.StudentService], but was actually of type [com.xxx.webserver.service.user.impl.StudentServiceImpl$$EnhancerBySpringCGLIB$$9f0ce91f]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:364)
..............................
解决方法:@Resource
private StudentService<Student, StudentForm> studentService;改为@Resource(name="studentService2")
private StudentService<Student, StudentForm> studentService;原理:默认按照名称进行装配,名称可以通过name属性进行指定,如果没有指定name属性,当注解写在字段上时,默认取字段名进行按照名称查找。com.xxx.webserver.service.user包下也有一个studentService接口,取bean时未指定名称导致到的..service.user包下的接口类型不匹配。
备注:...user包下的studentService实现类代码@Service("studentService")
public class StudentServiceImpl implements studentService
{
.......
}
相关文章推荐
- Aurora-hec4.0_scaninvoice_异常_04_org.springframework.beans.factory.BeanNotOfRequiredTypeException
- 处理异常:org.springframework.beans.factory.BeanNotOfRequiredTypeException
- 在使用Spring AOP 时,启动服务抛出异常: org.springframework.beans.factory.BeanNotOfRequiredTypeException
- 异常:org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException 错误,
- org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'faceAction' must be of
- 代理及注入之org.springframework.beans.factory.BeanNotOfRequiredTypeException
- 解决: org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException的解决办法
- org.springframework.beans.factory.BeanNotOfRequiredTypeException:
- org.springframework.beans.factory.BeanNotOfRequiredTypeException must be of type
- org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named "" must be of type [org.apache.struts.action.Action
- Spring-org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException:
- Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'dao' is exp
- "org.springframework.beans.factory.BeanNotOfRequiredTypeException……" 错误解决方案
- 运用spring时出现org.springframework.beans.factory.BeanNotOfRequiredTypeException: 错误
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill