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
在尝试启动一个包含Mybatis和SpringBoot的项目时,遇到Bean装配失败的问题,错误信息显示缺少特定类型的Mapper接口。解决方案是在启动类上添加@MapperScan注解,并指定Mapper接口所在包路径,以便SpringBoot在扫描时能找到对应的Mapper接口。
1047

被折叠的 条评论
为什么被折叠?



