java spring自动注入报错

深蓝浅爱 发布于 2016/03/14 14:24
阅读 1K+
收藏 0

【Gopher China万字分享】华为云的Go语言云原生实战经验!>>>

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actionRegister': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.esen.platform.data.IDataExchangeService com.esen.fatca.action.main.ActionRegister.dataExchangeService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.esen.platform.data.IDataExchangeService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=mq)}
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116)
 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:295)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
 at org.springframework.web.method.HandlerMethod.createWithResolvedBean(HandlerMethod.java:220)
 at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:234)
 at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:56)
 at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:298)
 at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091)
 at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1076)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:896)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
 at com.esen.fatca.server.FilterLoginCheck.doFilter(FilterLoginCheck.java:53)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
2016-03-14 06:19:58.799:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actionRegister': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.esen.platform.data.IDataExchangeService com.esen.fatca.action.main.ActionRegister.dataExchangeService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.esen.platform.data.IDataExchangeService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=mq)}:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.esen.platform.data.IDataExchangeService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=mq)}
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
 at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116)
 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:295)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
 at org.springframework.web.method.HandlerMethod.createWithResolvedBean(HandlerMethod.java:220)
 at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:234)
 at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:56)
 at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:298)
 at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091)
 at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1076)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:896)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
 at com.esen.fatca.server.FilterLoginCheck.doFilter(FilterLoginCheck.java:53)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
加载中
1
围城北
围城北
com.esen.platform.data.IDataExchangeService有没有实现类,实现类有没有定义@Service
0
wangkang80
wangkang80

应该是没有正确加注解吧,要么是service上没有加@service注解,要么就是属性上没有加@Autowired,当然也有可能是其他原因,从日志上看应该是这样.

关于spring的使用,请关注:http://git.oschina.net/wangkang/llsfw

希望能够帮到你.

0
深蓝浅爱

引用来自“王康”的评论

应该是没有正确加注解吧,要么是service上没有加@service注解,要么就是属性上没有加@Autowired,当然也有可能是其他原因,从日志上看应该是这样.

关于spring的使用,请关注:http://git.oschina.net/wangkang/llsfw

希望能够帮到你.

谢谢,问题已经解决
0
深蓝浅爱

引用来自“robot攻城师”的评论

com.esen.platform.data.IDataExchangeService有没有实现类,实现类有没有定义@Service
谢谢,问题已经解决
0
花米
花米
要把解决方法输出来,这样后面的人来了,才能帮到别人,不然你这个文章就没有任何存在的意义了!毕竟你已经解决了。
0
深蓝浅爱

引用来自“花米”的评论

要把解决方法输出来,这样后面的人来了,才能帮到别人,不然你这个文章就没有任何存在的意义了!毕竟你已经解决了。
好的
0
深蓝浅爱
解决方案:配置文件中的IDataExchangeService是自动注入的,但是在springMVC文件中没有配置读取路径,所以报错,后来讲配置文件的读取路径修改,就成功了 
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部