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


最近配置一個ssm的工程遇上了一個問題:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.xxxx.service.StudentInterface' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

經過長達1個小時的排查,終於解決了(汗顏!!!!!!!!!!!!)

首先:

1.查看applicationContext.xml 文件是否開啟自動掃描或者是否注入了bean

  建議可以用手動配置的方式注入bean 看是自動注入的問題還是接口的問題

2.查看@Autowired 注入的bean 是否寫錯

  

3.查看接口的實現類是否實現了改接口.

 

4.查看@service注解是否有寫.....

我的就是@service注解沒寫,主要是以前沒寫,也沒問題..所以一下子沒想到這個問題....


免責聲明!

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



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