org.springframework.beans.factory.UnsatisfiedDependencyException异常
2017-03-22 18:43
603 查看
这个异常是由于Spring在applicationContext.xml中bean的autowirte装配类型时出现问题。
在类型byName,byType,constructor三种类型中,可能会出现因无法自动装配而产生题目中的异常,在使用自动装配的时候,容易出现问题的JavaBean采用手动装配。
下面介绍一下关于autowrite的集中装配类型:
1)no:采用自动装配。必须使用ref直接饮用其他Bean<ref bean="JavaBean"/>
2)byName:以属性名区分自动装配。在容器中寻找与JavaBean属性名相同的JavaBean,并假期自动装配到JavaBean中。
3)byType:以属性类型区分自动转配
4)constructor:通过构造方法的参数类型自动装配
5)autudetect:首先使用constructor方式自动装配,然后使用byType方式
注意xml配置如果使用了通配符,请注意是否有些路径有遗漏,导致一些包没扫描到,例如<context:component-scan base-package="" />中
在类型byName,byType,constructor三种类型中,可能会出现因无法自动装配而产生题目中的异常,在使用自动装配的时候,容易出现问题的JavaBean采用手动装配。
下面介绍一下关于autowrite的集中装配类型:
1)no:采用自动装配。必须使用ref直接饮用其他Bean<ref bean="JavaBean"/>
2)byName:以属性名区分自动装配。在容器中寻找与JavaBean属性名相同的JavaBean,并假期自动装配到JavaBean中。
3)byType:以属性类型区分自动转配
4)constructor:通过构造方法的参数类型自动装配
5)autudetect:首先使用constructor方式自动装配,然后使用byType方式
注意xml配置如果使用了通配符,请注意是否有些路径有遗漏,导致一些包没扫描到,例如<context:component-scan base-package="" />中
相关文章推荐
- springboot Junittest 报异常:org.springframework.beans.factory.UnsatisfiedDependencyException:
- org.springframework.beans.factory.UnsatisfiedDependencyException异常
- org.springframework.beans.factory.UnsatisfiedDependencyException 异常这么解决
- 关于Spring中org.springframework.beans.factory.UnsatisfiedDependencyException异常
- org.springframework.beans.factory.UnsatisfiedDependencyException
- Spring使用@scope("session")爆org.springframework.beans.factory.UnsatisfiedDependencyException
- org.springframework.beans.factory.UnsatisfiedDependencyException
- spring + redis + org.springframework.beans.factory.UnsatisfiedDependencyException:
- org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name'se
- SSM中关于service中mapper注入失败org.springframework.beans.factory.UnsatisfiedDependencyException: Error crea
- org.springframework.beans.factory.UnsatisfiedDependencyException
- org.springframework.beans.factory.UnsatisfiedDependencyException
- Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean wi
- org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com
- 启动项目报错:org.springframework.beans.factory.UnsatisfiedDependencyException
- org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
- org.springframework.beans.factory.UnsatisfiedDependencyException
- 题目:org.springframework.beans.factory.BeanCreationException(hibernate中的jar包和spring中的jar包冲突)异常产生的原因和解决方案。
- SpringMvc常见异常之org.springframework.beans.factory.NoSuchBeanDefinitionException
- Spring读取配置文件org.springframework.beans.factory.BeanCreationException异常产生的原因和解决方案