最近配置一個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注解沒寫,主要是以前沒寫,也沒問題..所以一下子沒想到這個問題....