org.springframework.beans.factory.annotation.Autowired(required=true)


Injection of autowired dependencies failed

ERROR org.springframework.web.context.ContextLoader  - Context initialization failed
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.yisa.information.service.PersonService com.yisa.information.controller.SearchController.personService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.yisa.information.dao.PersonDao com.yisa.information.service.impl.PersonServiceImpl.pd; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.yisa.information.dao.PersonDao] 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)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204)。

 
對於該錯誤信息,由提示直觀翻譯即可知道是autowired標簽依賴注入失敗。
出現該錯誤的原因是由於用於訪問數據庫的DAO層中Bean未定義。直白說就是xxxxDaoImpl中忘了寫@Repository標簽。



 

還有一個原因是沒有在springMVC配置文件中沒有將service和respository注釋的包加入這里面,就是沒有被Spring掃描到

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM