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