-
SpringMVC Autowired 注入失败 求大神帮忙5
我用的是SpringMVC和Mybatis来做的
controller代码
service代码
dao代码、
启动tomcat时报错
问题补充:由于图片太大 我把异常信息帖出来
2013-10-24 16:47:18 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\java_tools\jdk1.6.0\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;D:\java_tools\jdk1.6.0\bin;D:\java_tools\jdk1.6.0\jre\bin;C:\Program Files\TortoiseSVN\bin;D:\java_tools\apache-maven-3.0\bin
2013-10-24 16:47:18 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-10-24 16:47:18 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 366 ms
2013-10-24 16:47:18 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-10-24 16:47:18 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.37
2013-10-24 16:47:18 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2013-10-24 16:47:18 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor icafe.xml
[DevLoader] Starting DevLoader
[DevLoader] projectdir=D:\project\icafebutler\web\src\main\webapp
[DevLoader] added file:/D:/project/icafebutler/web/target/classes/
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/resources.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/rt.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/jsse.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/jce.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/charsets.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/ext/dnsns.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/ext/localedata.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/ext/sunjce_provider.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/ext/sunmscapi.jar
[DevLoader] added file:/D:/java_tools/jdk1.6.0/jre/lib/ext/sunpkcs11.jar
[DevLoader] added file:/D:/project/icafebutler/common/target/classes/
[DevLoader] added file:/D:/project/icafebutler/common/target/test-classes/
[DevLoader] added file:/D:/repository/com/belerweb/pinyin4j/2.5.0/pinyin4j-2.5.0.jar
[DevLoader] added file:/D:/repository/com/shunwang/business-framework/1.0.0-SNAPSHOT/business-framework-1.0.0-SNAPSHOT.jar
[DevLoader] added file:/D:/repository/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar
[DevLoader] added file:/D:/repository/taglibs/standard/1.1.2/standard-1.1.2.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-context/3.2.2.RELEASE/spring-context-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-aop/3.2.2.RELEASE/spring-aop-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-beans/3.2.2.RELEASE/spring-beans-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-core/3.2.2.RELEASE/spring-core-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-expression/3.2.2.RELEASE/spring-expression-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-context-support/3.2.2.RELEASE/spring-context-support-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-tx/3.2.2.RELEASE/spring-tx-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-jdbc/3.2.2.RELEASE/spring-jdbc-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-orm/3.2.2.RELEASE/spring-orm-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-web/3.2.2.RELEASE/spring-web-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-webmvc/3.2.2.RELEASE/spring-webmvc-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/springframework/spring-test/3.2.2.RELEASE/spring-test-3.2.2.RELEASE.jar
[DevLoader] added file:/D:/repository/org/mybatis/mybatis/3.2.0/mybatis-3.2.0.jar
[DevLoader] added file:/D:/repository/org/mybatis/mybatis-spring/1.2.0/mybatis-spring-1.2.0.jar
[DevLoader] added file:/D:/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar
[DevLoader] added file:/D:/repository/asm/asm/1.5.3/asm-1.5.3.jar
[DevLoader] added file:/D:/repository/org/json/json/20090211/json-20090211.jar
[DevLoader] added file:/D:/repository/com/fasterxml/jackson/core/jackson-annotations/2.1.4/jackson-annotations-2.1.4.jar
[DevLoader] added file:/D:/repository/com/fasterxml/jackson/core/jackson-core/2.1.4/jackson-core-2.1.4.jar
[DevLoader] added file:/D:/repository/com/fasterxml/jackson/core/jackson-databind/2.1.4/jackson-databind-2.1.4.jar
[DevLoader] added file:/D:/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[DevLoader] added file:/D:/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[DevLoader] added file:/D:/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
[DevLoader] added file:/D:/project/icafebutler/service/target/classes/
[DevLoader] added file:/D:/project/icafebutler/service/target/test-classes/
[DevLoader] added file:/D:/project/icafebutler/persistence/target/classes/
[DevLoader] added file:/D:/project/icafebutler/persistence/target/test-classes/
[DevLoader] added file:/D:/repository/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar
[DevLoader] added file:/D:/repository/mysql/mysql-connector-java/5.1.26/mysql-connector-java-5.1.26.jar
[DevLoader] JSPCompiler Classpath = D:\project\icafebutler\web\target\classes;D:\java_tools\jdk1.6.0\jre\lib\resources.jar;D:\java_tools\jdk1.6.0\jre\lib\rt.jar;D:\java_tools\jdk1.6.0\jre\lib\jsse.jar;D:\java_tools\jdk1.6.0\jre\lib\jce.jar;D:\java_tools\jdk1.6.0\jre\lib\charsets.jar;D:\java_tools\jdk1.6.0\jre\lib\ext\dnsns.jar;D:\java_tools\jdk1.6.0\jre\lib\ext\localedata.jar;D:\java_tools\jdk1.6.0\jre\lib\ext\sunjce_provider.jar;D:\java_tools\jdk1.6.0\jre\lib\ext\sunmscapi.jar;D:\java_tools\jdk1.6.0\jre\lib\ext\sunpkcs11.jar;D:\project\icafebutler\common\target\classes;D:\project\icafebutler\common\target\test-classes;D:\repository\com\belerweb\pinyin4j\2.5.0\pinyin4j-2.5.0.jar;D:\repository\com\shunwang\business-framework\1.0.0-SNAPSHOT\business-framework-1.0.0-SNAPSHOT.jar;D:\repository\javax\servlet\jstl\1.1.2\jstl-1.1.2.jar;D:\repository\taglibs\standard\1.1.2\standard-1.1.2.jar;D:\repository\org\springframework\spring-context\3.2.2.RELEASE\spring-context-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-aop\3.2.2.RELEASE\spring-aop-3.2.2.RELEASE.jar;D:\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\repository\org\springframework\spring-beans\3.2.2.RELEASE\spring-beans-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-core\3.2.2.RELEASE\spring-core-3.2.2.RELEASE.jar;D:\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;D:\repository\org\springframework\spring-expression\3.2.2.RELEASE\spring-expression-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-context-support\3.2.2.RELEASE\spring-context-support-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-tx\3.2.2.RELEASE\spring-tx-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-jdbc\3.2.2.RELEASE\spring-jdbc-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-orm\3.2.2.RELEASE\spring-orm-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-web\3.2.2.RELEASE\spring-web-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-webmvc\3.2.2.RELEASE\spring-webmvc-3.2.2.RELEASE.jar;D:\repository\org\springframework\spring-test\3.2.2.RELEASE\spring-test-3.2.2.RELEASE.jar;D:\repository\org\mybatis\mybatis\3.2.0\mybatis-3.2.0.jar;D:\repository\org\mybatis\mybatis-spring\1.2.0\mybatis-spring-1.2.0.jar;D:\repository\cglib\cglib\2.1_3\cglib-2.1_3.jar;D:\repository\asm\asm\1.5.3\asm-1.5.3.jar;D:\repository\org\json\json\20090211\json-20090211.jar;D:\repository\com\fasterxml\jackson\core\jackson-annotations\2.1.4\jackson-annotations-2.1.4.jar;D:\repository\com\fasterxml\jackson\core\jackson-core\2.1.4\jackson-core-2.1.4.jar;D:\repository\com\fasterxml\jackson\core\jackson-databind\2.1.4\jackson-databind-2.1.4.jar;D:\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;D:\repository\xml-apis\xml-apis\1.0.b2\xml-apis-1.0.b2.jar;D:\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar;D:\project\icafebutler\service\target\classes;D:\project\icafebutler\service\target\test-classes;D:\project\icafebutler\persistence\target\classes;D:\project\icafebutler\persistence\target\test-classes;D:\repository\c3p0\c3p0\0.9.1.2\c3p0-0.9.1.2.jar;D:\repository\mysql\mysql-connector-java\5.1.26\mysql-connector-java-5.1.26.jar;D:/java_tools/apache-tomcat-6.0.37/lib/;D:/java_tools/apache-tomcat-6.0.37/lib/annotations-api.jar;D:/java_tools/apache-tomcat-6.0.37/lib/catalina-ant.jar;D:/java_tools/apache-tomcat-6.0.37/lib/catalina-ha.jar;D:/java_tools/apache-tomcat-6.0.37/lib/catalina-tribes.jar;D:/java_tools/apache-tomcat-6.0.37/lib/catalina.jar;D:/java_tools/apache-tomcat-6.0.37/lib/DevLoader.jar;D:/java_tools/apache-tomcat-6.0.37/lib/ecj-4.2.2.jar;D:/java_tools/apache-tomcat-6.0.37/lib/el-api.jar;D:/java_tools/apache-tomcat-6.0.37/lib/jasper-el.jar;D:/java_tools/apache-tomcat-6.0.37/lib/jasper.jar;D:/java_tools/apache-tomcat-6.0.37/lib/jsp-api.jar;D:/java_tools/apache-tomcat-6.0.37/lib/servlet-api.jar;D:/java_tools/apache-tomcat-6.0.37/lib/tomcat-coyote.jar;D:/java_tools/apache-tomcat-6.0.37/lib/tomcat-dbcp.jar;D:/java_tools/apache-tomcat-6.0.37/lib/tomcat-i18n-es.jar;D:/java_tools/apache-tomcat-6.0.37/lib/tomcat-i18n-fr.jar;D:/java_tools/apache-tomcat-6.0.37/lib/tomcat-i18n-ja.jar;D:/repository/;D:/java_tools/apache-tomcat-6.0.37/bin/bootstrap.jar;D:/java_tools/jdk1.6.0/lib/tools.jar;D:/java_tools/jdk1.6.0/jre/lib/ext/dnsns.jar;D:/java_tools/jdk1.6.0/jre/lib/ext/localedata.jar;D:/java_tools/jdk1.6.0/jre/lib/ext/sunjce_provider.jar;D:/java_tools/jdk1.6.0/jre/lib/ext/sunmscapi.jar;D:/java_tools/jdk1.6.0/jre/lib/ext/sunpkcs11.jar;
log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.DispatcherServlet).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2013-10-24 16:47:19 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'hello'
2013-10-24 16:47:20 org.apache.catalina.core.ApplicationContext log
严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.icafebutler.service.StudentService com.icafe.controller.HelloController.studentService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icafebutler.service.StudentService] 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.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.icafebutler.service.StudentService com.icafe.controller.HelloController.studentService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icafebutler.service.StudentService] 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$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
... 43 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icafebutler.service.StudentService] 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.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
... 45 more
2013-10-24 16:47:20 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /icafe threw load() exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icafebutler.service.StudentService] 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.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2013-10-24 16:47:20 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2013-10-24 16:47:20 org.apache.catalina.startup.HostConfig deployWAR
信息: Deploying web application archive icafebutler-web.war
2013-10-24 16:47:20 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\java_tools\apache-tomcat-6.0.37\webapps\icafebutler-web\WEB-INF\lib\servlet-api-6.0.29.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2013-10-24 16:47:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-10-24 16:47:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2013-10-24 16:47:20 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2013-10-24 16:47:20 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2013-10-24 16:47:20 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-10-24 16:47:20 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-10-24 16:47:20 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-10-24 16:47:20 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/27 config=null
2013-10-24 16:47:20 org.apache.catalina.startup.Catalina start
信息: Server startup in 2335 ms
2013年10月24日 16:52
9个答案 按时间排序 按投票排序
-
6楼讲的第三种情况多一些。我的就是这样解决的。
下面事spring-mvc配置的示例:
<!-- 扫描@Controler @Service -->
<context:component-scan base-package="com.cm.midstream" annotation-config="true" use-default-filters="false">
<context:include-filter type="regex" expression="/com.cm.midstream"/>
<context:exclude-filter type="regex" expression="/com.cm.midstream.common"/>
</context:component-scan>
这里扫描要把实体层规划到扫描范围内!2019年10月18日 17:50
-
1,@service放到实现上
2,在xml中配置扫描路径
<mvc:annotation-driven /> <context:component-scan base-package="com.xxx.service.impl com.xxx.controller"/>
2013年10月25日 10:34
-
spring默认会忽略掉扫描到接口类,具体实现参见ClassPathScanningCandidateComponentProvider.findCandidateComponents(String basePackage方法,关键代码
if (resource.isReadable()) { try { MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource); if (isCandidateComponent(metadataReader)) { ScannedGenericBeanDefinition sbd = new ScannedGenericBeanDefinition(metadataReader); sbd.setResource(resource); sbd.setSource(resource); if (isCandidateComponent(sbd)) { if (debugEnabled) { logger.debug("Identified candidate component class: " + resource); } candidates.add(sbd); } else { if (debugEnabled) { logger.debug("Ignored because not a concrete top-level class: " + resource); } } } else { if (traceEnabled) { logger.trace("Ignored because not matching any filter: " + resource); } } }
其中isCandidateComponent(sbd)的实现如下:protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { return (beanDefinition.getMetadata().isConcrete() && beanDefinition.getMetadata().isIndependent()); }
综上可知,对于在接口上注解spring是不会生成该bean的。2013年10月24日 18:55
-
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.icafebutler.service.StudentService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
spring生成studentService这个bean,应该讲@Autowired放在service实现上,而不是接口类上面。2013年10月24日 18:44
-
1. 你是否有用到JPA
2. 如果用到JPA那么在dao中要继承下jpa相关的接口
3. 如果不是那么可能涉及到 Student的实体类没有被扫描到2013年10月24日 17:10
-
看起来是因为你的 Service实现类没有 在 spring的配置域中定义。
要么在xml中声明该 Bean
要么在xml中用 context:component-scan 将该包中类加入搜索
<context:component-scan base-package="com.iteye.dwangel.service" use-default-filters="false">
<context:include-filter type="annotation" expression="com.iteye.dwangel.Service" />
</context:component-scan>
注使用context namespace需要在xml中加入相关声明:
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
">2013年10月24日 17:01
-
No qualifying bean of type [com.icafebutler.service.StudentService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
com.icafebutler.service.StudentService
找不到这个 Service
把 @Service 注解放在实现类上2013年10月24日 16:58
相关推荐
ssm-springMVC-整合Quartz(解决了无法注入service问题).doc
基于SpringMVC的用户三次登录失败案例,用户连续三次登录失败后,只有等24小时之后才可以登录。本案例为了演示,设置时间为2分钟,可以自行修改...
总结一下,"springmvc框架已做service注入"是指在 Spring MVC 项目中,Controller 类通过 Spring 的依赖注入机制,自动获得了 Service 类的实例,从而实现了业务逻辑和控制逻辑的分离。这一设计遵循了面向对象设计...
SpringMVC是Spring框架的一部分,专门用于构建Web应用程序。...通过这个实例,你可以了解如何利用SpringMVC的注解驱动、依赖注入特性,以及如何与MySQL数据库无缝集成,为开发高效、健壮的Web应用奠定基础。
SpringMVC提供了注解驱动的开发方式,简化了控制器的编写,如`@RequestMapping`用于映射URL请求,`@Autowired`用于依赖注入。 **Spring** 是一个全面的企业级应用框架,核心特性是依赖注入(DI)和面向切面编程...
SpringMVC 提供了丰富的注解,如 @RequestMapping、@Controller、@Service、@Autowired 等,使得开发者可以避免大量的 XML 配置,提高开发效率。通过注解,我们可以更直观地看到代码和它所对应的路由、依赖关系等。 ...
Mapper接口的实现通常会使用`@Mapper`注解,这样Spring能够自动扫描并管理这些接口,使得在Service层可以通过@Autowired注解直接注入并调用。 **整合SpringMVC和MyBatis** 1. **配置**:在Spring的配置文件中,...
DAO层通过Spring的@Autowired注解注入Mapper接口,实现业务操作。 7. **Service层**:创建Service层,定义业务逻辑,调用DAO层的方法。同样,Service也可以通过@Autowired注入DAO。 8. **Controller层**:创建...
4. 整合SpringMVC和Mybatis的教程,如何配置Spring的上下文以启用Mybatis,以及如何使用@Autowired注入Mapper。 5. 错误处理和日志记录的示例,帮助开发者调试和优化代码。 通过学习这些参考资料,开发者可以更好地...
在 SpringMVC 框架中,注解标签扮演着非常重要的角色,它们使得开发者可以轻松地定义控制器、请求映射、依赖注入等内容。在本文中,我们将详细地解释 SpringMVC 中常用的注解标签,包括@Controller、@RequestMapping...
总的来说,SpringMVC+Mybatis的整合是Java Web开发中常见的一种架构模式,它结合了Spring的优秀控制反转和依赖注入特性,以及Mybatis对数据库操作的高度定制性,为开发者带来了高效、可扩展的开发体验。
SpringMVC支持使用注解进行开发,如`@Controller`、`@RequestMapping`、`@Service`、`@Autowired`等,简化了XML配置。 6. **异常处理** 可以通过`@ExceptionHandler`注解自定义全局异常处理,或者配置`...
7. 服务层:编写Service接口及其实现,封装业务逻辑,通过@Autowired注入DAO层的实现。 8. 测试:使用JUnit或者Mockito进行单元测试,确保各个组件正常工作。 通过以上步骤,我们可以构建一个基于Maven、Spring、...
- `@Autowired`:自动注入依赖,可以注入Bean或其他资源。 - `@Service`:标记服务层类,配合@Autowired实现依赖注入。 - `@Repository`:标记数据访问层类,如DAO,便于异常处理。 **5. 事务管理** 在处理涉及多...
在实际的增删改查操作中,SpringMVC的Controller会调用Service层的方法,Service层再通过Autowired注入的Mapper接口,执行对应的数据库操作。例如,查询操作可以如下实现: 1. 在Mapper接口定义一个查询方法,如`...
- SpringMVC 5.1.5.RELEASE支持注解驱动开发,可以使用如@Service、@Autowired等注解简化组件装配。 10. **拦截器(Interceptor)**: - 拦截器允许在请求处理前后执行自定义逻辑,例如登录检查、性能监控等。 ...
- **使用@Autowired注入Mapper**:在需要使用Mapper的地方,通过@Autowired注解自动注入。 **4. 小游戏源码分析** 除了SpringMVC的基本教程和案例,提供的源码可能包含了一些小游戏的实现。这些源码可以帮助你理解...
2. 创建JdbcTemplate实例:在Spring配置文件中定义DataSource,然后通过`@Autowired`注解注入到JdbcTemplate bean中。 ```xml <!-- 数据源配置 --> ``` 3. 创建DAO层:创建一个接口,定义数据库操作的方法...