启动 SpringBoot项目报错:
Description:
Field xxMapper in com.xx.service.impl.xxServiceImpl required a bean of type 'com.xx.mapper.xxMapper' that could not be found.
Action:
Consider defining a bean of type 'com.xx.mapper.xxMapper' in your configuration.
报错原因:
项目未扫描到 mapper 包
解决办法:
在项目启动类上加注解 @MapperScan("Mapper文件所在的包"),@MapperScan 是扫描mapper类的注解,就不用在每个mapper类上加@MapperScan了。
@MapperScan("com.xx.mapper")
@SpringBootApplication
public class MallApplication {
public static void main(String[] args) {
SpringApplication.run(MallApplication.class, args);
}
}
再重新启动项目