spring+mybatis环境
在xml文件中自己写了SQL语言后,执行项目发现这个错误
后来我发现在target的编译目录中没有xml文件。
才明白对于未在resources目录下的xml文件,maven是默认不进行编译的。
解决:
1.将xml文件复制到target对应目录下(每次运行都要复制,不推荐)
2.将xml文件放到resources目录下(会改变我的mapper目录结构,不是很愿意)
3.进行配置:
(1)在pom文件中添加如下:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
(2)在spring boot的application.properties中添加如下:
包名记得修改。
mybatis-plus.mapper-locations=classpath:pri/ydy/eduService/mapper/xml/*.xml
如果这不是你的原因:
可参考:
https://blog.csdn.net/ppppfly/article/details/46847299?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param