解决异常Error creating bean with name ‘xxxxxController‘: Unsatisfied dependency expressed through field
错误信息如下:
Error creating bean with name 'dataInteractionController': Unsatisfied dependency expressed through field 'busiSysInfoService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'busiSysInfoServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.**NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.mapper.BusiSysInfoMapper' available**: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
分析
创建dataInteractionController这个bean出错,嵌套异常是busiSysInfoService不满足依赖,容器里面没有com.example.demo.mapper.BusiSysInfoMapper 的 实例,也就是说我们的busiSysInfoService对象不存在,导致注入失败,然后抛出了Error creating bean with name 'dataInteractionController这个异常,既然是busiSysInfoService这个对象的问题,那么我们就首先来分析,busiSysInfoService对象如何添加到容器,所以我们要看一下
1、busiSysInfoServiceImpl 是否加上@Service注解
2、busiSysInfoMapper 是否加上@Repository注解
如果以上都没有问题,考虑BusiSysInfo实体中各字段类型是否错误,如果都不存在,请一定考虑以下问题
沒有符合的bean可用文章来源:https://www.toymoban.com/news/detail-569708.html
解决办法
这种情况在DemoApplication中添加@MapperScan(basePackages = {“com.example.demo.mapper”}),我的问题是这样解决的。
希望对大家有用文章来源地址https://www.toymoban.com/news/detail-569708.html
到了这里,关于解决异常Error creating bean with name ‘xxxxxController‘: Unsatisfied dependency expressed through field的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!