问题描述
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'loginController':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatenet.viralpatel.spring3.service.AdminServicenet.viralpatel.spring3.controller.LoginController.adminService;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'adminServiceImpl':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatecom.hibernate.AdminDAOnet.viralpatel.spring3.service.AdminServiceImpl.adminDAO;nestedexceptionisorg.springframework.beans.factory.NoSuchBeanDefinitionException:Nomatchingbeanoftype[com.hibernate.AdminDAO]foundfordependency:expectedatleast1beanwhichqualifiesasautowirecandidateforthisdependency.Dependencyannotations:{@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=adminDAO)}org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)javax.servlet.GenericServlet.init(GenericServlet.java:160)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)java.lang.Thread.run(Thread.java:619)
解决方案
解决方案二:
异常信息不全吧,主要看下面的Causeby...
解决方案三:
exceptionisorg.springframework.beans.factory.NoSuchBeanDefinitionException:Nomatchingbeanoftype[com.hibernate.AdminDAO]foundfordependency:expectedatleast1beanwhichqualifiesasautowirecandidateforthisdependency很明显了
解决方案四:
你这个dao是哪里实例化的@org.springframework.beans.factory.annotation.Qualifier(value=adminDAO)看看它的的id是不是adminDAO
解决方案五:
现在变成这样子了rg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'loginController':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatenet.viralpatel.spring3.service.AdminServicenet.viralpatel.spring3.controller.LoginController.adminService;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'adminServiceImpl':Injectionofautowireddependenciesfailed;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Couldnotautowirefield:privatenet.viralpatel.spring3.dao.AdminDAOnet.viralpatel.spring3.service.AdminServiceImpl.adminDAO;nestedexceptionisorg.springframework.beans.factory.NoSuchBeanDefinitionException:Nomatchingbeanoftype[net.viralpatel.spring3.dao.AdminDAO]foundfordependency:expectedatleast1beanwhichqualifiesasautowirecandidateforthisdependency.Dependencyannotations:{@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=adminDAO)}org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)javax.servlet.GenericServlet.init(GenericServlet.java:160)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)java.lang.Thread.run(Thread.java:619)
解决方案六:
不能根据这个名字创建bean,你看你的loginController是否存在,其实你看看你是否有cglib包?