org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBizImpl'

原创 2016年06月01日 12:03:27

最近在整合spring、spring-mvc、mybatis框架的时候,在用maven中的插件jetty来调试程序的时候,出现了以下问题:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBizImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.spring.dao.TUserMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER)}|Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TUserMapper' defined in file [E:\workspace\sample-webapp\target\classes\com\spring\dao\TUserMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/spring/sqlmap/*Mapper.xml]: class path resource [com/spring/sqlmap/] cannot be resolved to URL because it does not exist
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:800)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)

简单的来说,就是biz层中的dao对象没有注入,我百思不得其解,用tomcat测试了一下,发现没有这个问题,于是认识到是jetty的问题。

解决方法:

在eclipse中右键项目,选择maven,选择UpdateProject选项,再次在jetty中运行项目,则运行成功~

相关文章推荐

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAction'

在SSH中一个常见的Action创建异常,当启动Tomcat时:严重: Exception sending context initialized event to listener instance...

ssh搭建 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessio

转载问题解决办法

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'g': Injectio

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Exception in thr...

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's

问题:整合Hibernate和Spring,测试过程中报错:Caused by: org.springframework.beans.factory.BeanCreationException: Er...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFa

希望能帮到你。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lanagerServi

org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested ...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx'

Spring Web MVC开发时,遇到如下错误:严重: Context initialization failed org.springframework.beans.factory.BeanCre...

关于org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFac

今天在做s2sh

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserDao' def

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserDao' d...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.

1、缺少commons-collections-3.1.jar包导致,引入该包即可。 2014-03-31 16:05:20,967 ERROR [org.springframework.w...
  • pcxbest
  • pcxbest
  • 2014年03月31日 16:13
  • 13576
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBizImpl'
举报原因:
原因补充:

(最多只允许输入30个字)