Error creating bean with name 'controller':Injection of resource dependencies failed
使用@Resource注入,启动tomcat时抛出异常(解决办法在异常信息下面):
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.guilinzhicheng.mapper.FindClassMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class Java.lang.Object, authenticationType=Container)}at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)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:602)at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521)at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462)at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)at javax.servlet.GenericServlet.init(GenericServlet.java:241)at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:736)at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)at org.mortbay.jetty.Server.doStart(Server.java:224)at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)at runjettyrun.Bootstrap.main(Bootstrap.java:97)2015-11-26 13:48:46.875:INFO::Started SelectChannelConnector@0.0.0.0:8080
解决方法:在web.xml中需配置:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
ContextLoaderListener:在web容器启动时,自动装配ApplicationContext的配置信息
更多推荐
所有评论(0)