在spring中,出现bean无法加载到的情况
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘XXXXX’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory1.getObject(AbstractBeanFactory.java:306)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)atorg.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)atorg.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)atorg.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)atorg.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)atjavax.servlet.GenericServlet.init(GenericServlet.java:158)atorg.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144)atorg.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)atorg.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)atorg.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4978)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5290)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4978) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5290) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase1.getObject(AbstractBeanFactory.java:306)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)atorg.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634)atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682)atorg.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553)atorg.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494)atorg.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)atjavax.servlet.GenericServlet.init(GenericServlet.java:158)atorg.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144)atorg.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)atorg.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:983)atorg.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4978)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5290)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1423)
at org.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1413)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorStartChild.call(ContainerBase.java:1413) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutorStartChild.call(ContainerBase.java:1413)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
查看要加载的类是否添加了注解
查看spring的配置文件是否扫描到到相对应的包