org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ylx.mapper.TbBrandMapper com.ylx.service.sellergoods.BranService.tbBrandMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.ylx.mapper.TbBrandMapper] 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)}
這個是錯誤信息:先說下解決的思路java
先檢查的Service實現層dubbo
有沒有掃描此包web
<dubbo:annotation package="包名" />
在web.xml
中的listener
有沒有監聽到dao(mybatis生成的mapper(java文件))
和service(Service的實現類文件)
的配置文件spring
注意一些model生成的打包方式(必定要看清楚)數據庫
在上面的這些配置我檢查了無數次(包括和別人對照代碼),仍是出現這個錯誤,這個時候有點懷疑是否是這兩個配置文件根本就沒有加載。mybatis
ContextLoaderListener
初始化的。由於這個service一直不能夠建立,全部多是這個加載配置文件的web.xml
文件沒有加載到這兩個配置文件。app
由於我一直感受高版本的不靠譜,我就將4.0
換成了2.5
。maven
而後maven
中從新clear install.ui
運行程序,完美解決,**Service不能建立竟然是web.xml版本問題
this
這個只是發生錯誤的一種解決方案,多是其它的問題引發的這個錯誤,此文僅供參考code