解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'

1. 启动 springboot 项目报错:

Field userMapper in gentle.service.impl.UserServiceImpl 
required a bean of type 'gentle.mapper.UserMapper' that could not be found

解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'_第1张图片

2. 原因,项目未扫描到 mapper 包。

3. 解决:

在项目启动类上加注解  @MapperScan

如下:

解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'_第2张图片

4. 重启工程成功运行:

解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'_第3张图片

 

你可能感兴趣的:(坑,傻踩傻乐,...)