前言:在使用同事封装的自定义通用mapper接口工具模块时,出现扫描不到业务模块的mapper接口报出控制器、服务实现类依赖无法满足问题。
错误类似以下内容(当时并没有保存日志):
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.minibike.bike.user.dao.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}”
1.从日志得到的信息
控制器、服务实现类的依赖无法满足是因为UserMapper这个bean没有被注入(可以从该句看出:expected at least 1 bean which qualifies as autowire candidate.)
2.大致的分析
既然UserMapper这个bean没有被装配成功,那么问题可能出现在Mapper包的扫描上。(mapper包