org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'xxx 'available


  搭了一個簡單的SSM項目,啟動報錯:

  org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.xxx.ssmdemo.service.IUserService' available: expected at least 1 bean

  which qualifies as autowire candidate.Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  提示很清楚,找不到IUserService這個Bean的定義,所以自動注入出錯。那么找不到Bean,可能有兩種情況,一是真的沒有定義這個接口(不太可能),二就是Spring沒有掃描到相關的類或者接口。

  原因:項目中有spring-mvc.xml,spring-mybatis.xml,applicationContext.xml共三個配置文件。而我在前兩個配置文件中都添加了<context : compoment-scan>,在applicationContext.xml中卻沒有配。

  解決:將其余配置文件中的<context : compoment-scan>刪除,在applicationContext中添加。

  啟動成功。

 


免責聲明!

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



猜您在找 Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "" available: expected at least 1 bean which qualifies as autowire candidate 解決 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type的問題 springboot啟動報錯:Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zxkj.lockserver.dao.CompanyDao' available: expected at least 1 bean which qua org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException 錯誤之Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined 報錯!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined 多個@bean無法通過@resource注入對應的bean(org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found )
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM