mybatis整合在springboot中时,出现 class path resource [mapper/*.xml] cannot be opened because it does not exist

如图所示,报错如下

 

 可以看到它提示说我的resource下面没有mapper/*.xml相关的文件,当时就给我整蒙了

我一查target文件夹

 

 发现我的UserMapper在

 

最后才找到问题所在,三种所针对的都不一样:

# 指定 mybatis 映射文件位置
mybatis.config-locations=classpath:xxx/*.xml

# locations写错成location,springboot就找MyBatis主配置文件,如果这个文件没有就会报错
mybatis.config-location=classpath:xxx/*.xml

mybatis.mapper-locations=classpath:xxx/*.xml

 

疯狂找bug😂

posted @ 2022-11-08 15:34  lhbili  阅读(1095)  评论(0)    收藏  举报