今天写一个接口,所有的都写完了后来测试。整个项目是用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.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用于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.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Error ...
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.0.M4.jar
org.springframework.beans-sources-3.0.5.release.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.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...
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-3.1.0.M2
org.springframework.beans.factory org.springframework.beans.factory.access org.springframework.beans.factory.access.el org.springframework.beans.factory.annotation org.springframework.beans.factory....
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....
org.springframework.beans-3.1.0.RELEASE.jar
Maven坐标:org.springframework:spring-beans:5.0.10.RELEASE; 标签:spring、beans、springframework、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可...
org.springframework.beans-3.0.0.M3.jar
Maven坐标:org.springframework:spring-beans:5.2.0.RELEASE; 标签:springframework、spring、beans、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
org.springframework.beans-2.5.5.A.jar, org.springframework.beans-2.5.6.A.jar, org.springframework.beans-2.5.6.SEC01.jar, org.springframework.beans-3.0.0.M1.jar, ...org.springframework.beans.jar
org.springframework.beans-3.0.0.CI-331.jar的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...