Mybatis与springboot项目,启动时报错,详细的错误如下:
Field mapper in 'xxx' required a bean of type 'xxx' that could not be found. Action: Consider defining a bean of type ‘xxx’ in your configuration.
原因是bean装配失败,springboot扫描时没有找到@Mapper对应的接口。
解决方法: 在启动类前加上:
@MapperScan(basePackages = { "mapper所在的包路径" })
扫描mapper包下的所有mapper