`
远去的渡口
  • 浏览: 472818 次
  • 性别: Icon_minigender_2
  • 来自: 上海转北京
社区版块
存档分类
最新评论

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching解决方案

 
阅读更多

今天写一个接口,所有的都写完了后来测试。整个项目是用spring-mvc的框架,使用ibatis做数据库层操作。

用jetty:run启动时老报错。

指向的是我的一个dao类bean找不到定义,我明明写了

@Autowired private ApiCouponPresentDao apiCouponPresentDao; 注入代码的呀,一直没想起来哪里有错。

错误信息是:

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

'apiWechatService': Injection of autowired dependencies failed; nested exception is 

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private 

com.tongcard.api.services.ApiCouponService 

com.tongcard.api.services.impl.ApiWechatServiceImpl.apiCouponService; nested exception is 

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

'apiCouponService': Injection of autowired dependencies failed; nested exception is 

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private 

com.tongcard.api.daos.ApiCouponPresentDao 

com.tongcard.api.services.impl.ApiCouponServiceImpl.apiCouponPresentDao; nested exception is 

org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type 

[com.tongcard.api.daos.ApiCouponPresentDao] 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)}
	at 

org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProces

sPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
	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.preInstantiateSingleton

s(DefaultListableBeanFactory.java:609)
	at 

org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitializati

on(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:672)
	at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized

(ServletContextHandler.java:403)
	at org.eclipse.jetty.server.handler.ContextHandler.startContext

(ContextHandler.java:664)

 

后来查找其他的类似引用的bean,搜索后发现在spring-biz.xml里面有配置,而这个类是我新加的,我忘记写上配置了。

于是在配置文件中加入这个新的dao的定义后,再启动就正常了。spring-mvc使用还不熟,不过这一点都忘记了的确不应该,记录一下。

分享到:
评论

相关推荐

    org.spring-framework-3.0.4. 所有jar

    org.springframework.beans-3.0.4.RELEASE.jar org.springframework.context.support-3.0.4.RELEASE.jar org.springframework.context-3.0.4.RELEASE.jar org.springframework.core-3.0.4.RELEASE.jar org....

    org.springframework.flex-1.0.3.RELEASE.jar.zip

    org.springframework.flex-1.0.3.RELEASE.jar.zip用于JAR包,org.springframework.flex-1.0.3.RELEASE.jar.zip用于JAR包org.springframework.flex-1.0.3.RELEASE.jar.zip用于JAR包org.springframework.flex-1.0.3....

    org.springframework.transaction-3.1.2.RELEASE.zip

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...

    org.springframework.web.servlet-3.0.1.RELEASE-A.jar

    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Error ...

    spring3.0.5 所有jar文件

    org.springframework.beans-3.0.5.RELEASE.jar org.springframework.context-3.0.5.RELEASE.jar org.springframework.context.support-3.0.5.RELEASE.jar org.springframework.core-3.0.5.RELEASE.jar org.spring...

    aopalliance-1.0.jar,org.springframework.aop-3.0.0.RELEASE.jar

    aopalliance-1.0.jar,org.springframework.aop-3.0.0.RELEASE.jar,org.springframework.jdbc-3.0.0.RELEASEorg.springframework.beans-3.0.0.RELEASE.jar等

    org.springframework.beans-3.0.5工程所需jar包

    org.springframework.beans-3.0.5工程所需jar包,com.springsource.net.sf.cglib-2.2.0.jar、 com.springsource.org.apache.commons.logging-1.1.1.jar、 javax.inject.jar、 javax.servlet.jsp.jar、 org.spring...

    org.springframework.beans-3.0.0.M4.jar

    org.springframework.beans-3.0.0.M4.jar

    org.springframework.web.jar

    9. **Integration with other Spring Modules**:`org.springframework.web.jar`与Spring框架的其他模块紧密集成,如Spring Core、Spring Beans、Spring AOP等,共同构建出一个完整的应用框架。 总的来说,`org....

    org.springframework.beans-sources-3.0.5.release.jar

    org.springframework.beans-sources-3.0.5.release.jar

    org.springframework.test-3.0.2.RELEASE.jar

    import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @...

    spring3.1 官方全部jar包

    org.springframework.beans-3.1.RELEASE.jar org.springframework.context.support-3.1.RELEASE.jar org.springframework.context-3.1.RELEASE.jar org.springframework.core-3.1.RELEASE.jar org.spring...

    Spring所需jar包

    org.springframework.beans-3.0.0.RELEASE.jar org.springframework.context.support-3.0.0.RELEASE.jar org.springframework.context-3.0.0.RELEASE.jar org.springframework.core-3.0.0.RELEASE.jar org.spring...

    org.springframework.beans.factory.config.PropertyPlaceholderConfigurer

    `org.springframework.beans.factory.config.PropertyPlaceholderConfigurer` 是Spring框架中的一个重要组件,主要负责处理配置文件中的占位符替换。这个类是Spring在初始化bean时用来解析和注入环境变量或系统属性...

    spring3.1.1jar及其关联jar

    org.springframework.beans-3.1.1.RELEASE org.springframework.context.support-3.1.1.RELEASE org.springframework.context-3.1.1.RELEASE org.springframework.core-3.1.1.RELEASE org.springframework....

    org.springframework.beans-3.1.0.M2

    org.springframework.beans-3.1.0.M2

    asm-3.2.3.jar

    org.springframework.beans.factory org.springframework.beans.factory.access org.springframework.beans.factory.access.el org.springframework.beans.factory.annotation org.springframework.beans.factory....

    测试spring中的org.springframework.beans.factory.InitializingBean

    在Spring框架中,`org.springframework.beans.factory.InitializingBean`接口是一个非常重要的概念,它用于标记那些需要在初始化完成后执行特定逻辑的bean。这个接口只包含一个方法:`afterPropertiesSet()`,当bean...

    spring3.0.0相关jar包

    org.springframework.beans-3.0.0.RELEASE org.springframework.context.support-3.0.0.RELEASE org.springframework.context-3.0.0.RELEASE org.springframework.core-3.0.0.RELEASE org.springframework....

    解决The type org.springframework.dao.support.DaoSupport cannot be resolved.bao报错

    从提供的文件列表看,有两个Spring库:`org.springframework.beans-3.0.2.RELEASE.jar`和`spring-tx-3.2.4.RELEASE.jar`。`DaoSupport`位于`spring-dao`模块中,而不是这两个jar中。你需要确保你的构建配置(如Maven...

Global site tag (gtag.js) - Google Analytics