程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> spring mvc-spring中提示BeanCreationException

spring mvc-spring中提示BeanCreationException

編輯:編程綜合問答
spring中提示BeanCreationException
  1. 2015-05-24 22:16:48,030 ERROR [org.springframework.web.servlet.DispatcherServlet] - Context initialization failed
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aomRapsController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.thinkgem.jeesite.modules.rap.service.AomRapsService com.thinkgem.jeesite.modules.rap.web.AomRapsController.somRapsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aomRapsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.thinkgem.jeesite.common.persistence.CrudDao com.thinkgem.jeesite.common.service.CrudService.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.thinkgem.jeesite.common.persistence.CrudDao] 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)}
  3. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:301)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
  8. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
  10. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  11. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
  12. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
  13. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
  14. at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
  15. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
  16. at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
  17. at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
  18. at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
  19. at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  20. at javax.servlet.GenericServlet.init(GenericServlet.java:160)
  21. at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
  22. at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
  23. at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:865)
  24. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
  25. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
  26. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
  27. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
  28. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
  29. at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
  30. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
  31. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
  32. at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
  33. at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
  34. at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
  35. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  36. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  37. at java.lang.Thread.run(Thread.java:744)
  38. Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.thinkgem.jeesite.modules.rap.service.AomRapsService com.thinkgem.jeesite.modules.rap.web.AomRapsController.somRapsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aomRapsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.thinkgem.jeesite.common.persistence.CrudDao com.thinkgem.jeesite.common.service.CrudService.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.thinkgem.jeesite.common.persistence.CrudDao] 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)}
  39. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:522)
  40. at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
  41. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:298)
  42. ... 34 more
  43. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aomRapsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.thinkgem.jeesite.common.persistence.CrudDao com.thinkgem.jeesite.common.service.CrudService.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.thinkgem.jeesite.common.persistence.CrudDao] 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)}
  44. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:301)
  45. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186)
  46. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
  47. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
  48. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
  49. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
  50. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
  51. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
  52. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:271)
  53. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  54. at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1021)
  55. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:964)
  56. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:862)
  57. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:494)
  58. ... 36 more圖片說明圖片說明

最佳回答:


@Autowired 會自動尋找你定義的這個class的類名的首字母小寫的spring bean的定義。所以這個取決於你用的這個AomRapsService是怎麼定義的。如果它也是通過在AomRapsService上面加上@Service的方式來定義,那spring會自動生成一個bean id="aomRapsService"的spring bean。但是如果這個class的定義是自己在spring xml裡面寫了一個bean id="AomRapsService"的spring bean,這種autowired的方式會失敗。解決方法是使用@Resource(name=“AomRapsService”)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved