- 1、问题描述
- 2、问题原因
- 2.1 在application.yml文件中配置mapper-locations
- 2.2 在pom.xml文件中指定mapper.xml位置
Property 'mapperLocations' was not specified or no matching resources found
今天在使用mybatisplus启动项目的时候,控制台输出了如下日志,这是由于xml文件没有被扫描到导致的。
我的项目结构如下
我们可以去查看targets目录下面生产的文件,发现并没有xml后缀的文件。
2、问题原因 springboot项目启动的时候,src/main/java目录里只会扫描.java文件,而我的mapper.xml也是放在这个目录下的,导致它不能被扫描到。所以我们需要指定mapper.xml文件的位置。
2.1 在application.yml文件中配置mapper-locationsmapper-locations: classpath:com/weibo/message/mapper/xml/*.xml
路径根据自己的情况设置,或者为了方便直接写成classpath:**/mapper/xml**.xml
src/main/resources



