spring整合mybatis报.UnsatisfiedDependencyException错误
tomcat启动报org.springframework.beans.factory.UnsatisfiedDependencyException:错误
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookController': Unsatisfied dependency expressed through field 'bookService'; nested exception is org.springframework.beans.factory.NoSuchB  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
at t.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at t.fresh(AbstractApplicationContext.java:549)
at org.springframework.web.figureAndRefreshWebApplicationContext(FrameworkServlet.java:701)
at org.springframework.web.ateWebApplicationContext(FrameworkServlet.java:667)
at org.springframework.web.ateWebApplicationContext(FrameworkServlet.java:715)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.StandardWrapper.initServlet(StandardWrapper.java:1132)
at org.StandardWrapper.loadServlet(StandardWrapper.java:1079)
at org.StandardWrapper.load(StandardWrapper.java:973)
at org.StandardContext.loadOnStartup(StandardContext.java:4885)
at org.StandardContext.startInternal(StandardContext.java:5199)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.ContainerBase.addChild(ContainerBase.java:719)
at org.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1720)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:498)
at deler.BaseModelMBean.invoke(BaseModelMBean.java:287)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.ateStandardContext(MBeanFactory.java:483)
[2019-08-26 06:45:42,635] Artifact MySSM:war exploded: Artifact is deployed successfully
[2019-08-26 06:45:42,635] Artifact MySSM:war exploded: Deploy took 8,803 milliseconds
at org.apache.catalina.ateStandardContext(MBeanFactory.java:432)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:498)
at deler.BaseModelMBean.invoke(BaseModelMBean.java:287)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at com.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at i.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at i.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at i.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.jav
a:1309)
at java.security.AccessController.doPrivileged(Native Method)
at i.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
at i.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:498)
i.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
i.transport.Transport$1.run(Transport.java:200)
i.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
i.transport.Transport.serviceCall(Transport.java:196)
p.TCPTransport.handleMessages(TCPTransport.java:573)
p.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
p.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
p.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)spring framework
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of
type 'ain.ssm.service.BookService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:  at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1658)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1217)
at org.springframework.beans.factory.solveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
... 69 more
原因,l中未添加ContextLoaderListener。
⾃⼰搭建SSM环境坑了很久,了⼀天才到这个原因,特此记录⼀下。
ContextLoaderListener的作⽤:
当启动web容器时。⾃动装配l的配置信息

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。