关于class path resource [mapper/*Mapper.xml] cannot be opened because it does no exists异常的一些记录
这是用springboot整合mybatis时遇到的一个小问题,问题虽小,但是也耽误了很多时间,搜了很多博客,但大多都是复制粘贴的废话,说不到点子上,最终花了蛮久才找到一个有用的。特此记录一下。
关于问题:
问题讲的是mapper文件不存在,那要么就是你真的没有这个文件,要么就是application.properties(或者application.yaml)配置出错了。我就是配置文件写错了。。。
我之前写的,这样找不到xml文件内:
mybatis.config-location=classpath:mapper/*Mapper.xml
要用下面这样就可以了:
mybatis.mapper-locations=classpath:mapper/*Mapper.xml
本文记录了在使用SpringBoot整合Mybatis时遇到的mapper文件找不到的问题,问题源于配置文件中mybatis.config-location的错误写法。正确配置应为mybatis.mapper-locations=classpath:mapper/*Mapper.xml,而非mybatis.config-location=classpath:mapper/*Mapper.xml。通过调整这一配置,成功解决了XML文件无法被加载的问题。
1323

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



