解决异常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实体中各字段类型是否错误,如果都不存在,请一定考虑以下问题
解决异常Error creating bean with name ‘xxxxxController‘: Unsatisfied dependency expressed through field-小白菜博客
沒有符合的bean可用

解决办法

这种情况在DemoApplication中添加@MapperScan(basePackages = {“com.example.demo.mapper”}),我的问题是这样解决的。
解决异常Error creating bean with name ‘xxxxxController‘: Unsatisfied dependency expressed through field-小白菜博客
希望对大家有用