SSM框架---容器创建注入对象失败
2016-10-11 23:38
1751 查看
严重: Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name'bsxrServiceImpl':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field:
private com.bj.dao.BsxrDao com.bj.service.BsxrServiceImpl.dao; nested
exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [com.bj.dao.BsxrDao] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'bsxrDao' defined in file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.
core\tmp0\wtpwebapps\port_1\WEB-INF\classes\com\bj\dao\BsxrDao.class]: Invocation
of init method failed; nested exception 。。。。。。。。
这个异常网上有很多说法,尝试多种办法都没有解决。
Error creating bean with name 'bsxrServiceImpl' 注解我是使用的@Autowired ,出现上述异常,困惑了将近一天;
@Autowired 后面加上 (required = false); 不再报 上述异常,但是有新异常
expected com.bj.dao.BsxrDao, but found com.bj.dao,看来是
BeanCreationException: Error creating bean with name 'bsxrServiceImpl': 这个异常把
expected com.bj.dao.BsxrDao, but found com.bj.dao异常给掩盖掉了。
@Autowired(required = false)会使expected com.bj.dao.BsxrDao, but found com.bj.dao异常显现出来,BeanCreationException: Error creating bean with name
'bsxrServiceImpl': 异常不再显示。
所以才发现根本原因,并不是spring的配置文件以及注解的错误。异常BeanCreationException: Error creating bean with name
'bsxrServiceImpl':把真是的报错原因expected com.bj.dao.BsxrDao, but found com.bj.dao给隐藏了。
异常expected com.bj.dao.BsxrDao, but found com.bj.dao就简单了,检查发现使用的mapper的动态代理,但是namespace应该写全限定性接口名,自己写错了,,更改后终于解决问题。
总结:
BeanCreationException: Error creating bean with name
'bsxrServiceImpl': 原因之一就是 mapper动态代理 mapper.xml namespace属性写错了。
感谢http://darkmasky.iteye.com/blog/1129828 博主给我的启发,非常感谢。
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name'bsxrServiceImpl':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field:
private com.bj.dao.BsxrDao com.bj.service.BsxrServiceImpl.dao; nested
exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [com.bj.dao.BsxrDao] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'bsxrDao' defined in file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.
core\tmp0\wtpwebapps\port_1\WEB-INF\classes\com\bj\dao\BsxrDao.class]: Invocation
of init method failed; nested exception 。。。。。。。。
这个异常网上有很多说法,尝试多种办法都没有解决。
Error creating bean with name 'bsxrServiceImpl' 注解我是使用的@Autowired ,出现上述异常,困惑了将近一天;
@Autowired 后面加上 (required = false); 不再报 上述异常,但是有新异常
expected com.bj.dao.BsxrDao, but found com.bj.dao,看来是
BeanCreationException: Error creating bean with name 'bsxrServiceImpl': 这个异常把
expected com.bj.dao.BsxrDao, but found com.bj.dao异常给掩盖掉了。
@Autowired(required = false)会使expected com.bj.dao.BsxrDao, but found com.bj.dao异常显现出来,BeanCreationException: Error creating bean with name
'bsxrServiceImpl': 异常不再显示。
所以才发现根本原因,并不是spring的配置文件以及注解的错误。异常BeanCreationException: Error creating bean with name
'bsxrServiceImpl':把真是的报错原因expected com.bj.dao.BsxrDao, but found com.bj.dao给隐藏了。
异常expected com.bj.dao.BsxrDao, but found com.bj.dao就简单了,检查发现使用的mapper的动态代理,但是namespace应该写全限定性接口名,自己写错了,,更改后终于解决问题。
总结:
BeanCreationException: Error creating bean with name
'bsxrServiceImpl': 原因之一就是 mapper动态代理 mapper.xml namespace属性写错了。
感谢http://darkmasky.iteye.com/blog/1129828 博主给我的启发,非常感谢。
相关文章推荐
- Spring.NET依赖注入框架学习-- 泛型对象的创建和使用
- SpringIOC容器创建对象及依赖注入的几种方式
- 学习SSM框架笔记二:spring容器实例化对象的3种方法
- 一起写框架-Ioc内核容器的实现-对象的调用-方法注入容器的对象(十一)
- SSM框架之spring学习1——创建对象,处理依赖关系
- 一起写框架-Ioc内核容器的实现-对象的调用-@Bean注解注入容器的对象(十二)
- 一起写框架-Ioc内核容器的实现-对象的调用-属性注入容器的对象(十)
- spring 之脱离容器管理创建的对象进行依赖注入
- SSH框架之Spring的IOC容器的创建对象、对象依赖关系(1)
- 使用脚本自动创建AD中的层次化结构容器及对象
- 解决多文档程序框架中建立新的子框架类后出现“创建空文档失败”的问题
- 将显示对象置于PopUpManager创建的显示容器之上
- 创建你自己的依赖注入容器Ioc Container(转)
- web 容器拿到spring 注入的对象
- Spring通过容器获取配置对象及事件注入(学习笔记二)
- 微软企业库4.1学习笔记(五)对象创建和依赖注入方法
- 在YII框架中有2中方法创建对象:
- 创建你自己的依赖注入容器Ioc Container
- 微软企业库4.1学习笔记(五)对象创建和依赖注入方法
- Caliburn笔记-依赖注入容器(wpf框架)