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的問題 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.yang.service.StudentInterface' available: expected at least 1 bean which qualifies as autowire candidate Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.thinkplatform.dao.UserLogDao' available: expected at least 1 bean which qualifies as autowi 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 springboot 報錯 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有沒有大佬出個主意,我找了一天,剛入門springboot spring Boot異步操作報錯誤: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Spring 報錯 :org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'statementController' available Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'user' available
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM