spring Boot 启动遇到 Consider defining a bean of type 'com.xxx.mapper.UserMapper'

323 阅读1分钟

错误:

Description:

Parameter 0 of constructor in com.xxx.service.impl.UserServiceImpl required a bean of type 'com.xxx.mapper.UserMapper' that could not be found.


Action:

Consider defining a bean of type 'com.xxx.mapper.UserMapper' in your configuration.

翻译过来就是:没有找到 UserMapper ,所以启动就报错了。

解决办法

在spring boot 启动类上添加注解 @MapperScan,扫描mapper包就可以了

@MapperScan("com.xxx.mapper")