错误: Error creating bean with name 'studentController': Unsatisfied dependency expressed through field 'studentServiceImpl';

详细错误:

 1 严重: Context initialization failed
 2 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController': Unsatisfied dependency expressed through field 'studentServiceImpl'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentServiceImpl': Unsatisfied dependency expressed through field 'studentDaoImpl'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.mgy.dao.StudentDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
 3     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
 4     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
 5     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
 6     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268)
 7     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 8     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
 9     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
10     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
11     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
12     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
13     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
14     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
15     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
16     at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)
17     at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)
18     at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)
19     at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)
20     at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)
21     at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171)
22     at javax.servlet.GenericServlet.init(GenericServlet.java:158)
23     at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144)
24     at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
25     at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:773)
26     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
27     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
28     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
29     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
30     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
31     at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
32     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
33     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
34     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
35     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
36     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
37     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
38     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
39     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
40     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
41     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
42     at java.lang.Thread.run(Thread.java:748)

解决方案:

public class StudentDaoImpl implements StudentDao 类忘记加 @Repository 注解,加上就可以解决问题了

posted @ 2019-04-19 21:51  梦在原地  阅读(49559)  评论(0编辑  收藏  举报