正确使用mapper编写sql语句
使用MP的xml编写sql语句的时候,有时候会报错,(not found)

原因:
maven的默认加载机制,只会把文件夹中src - main - java文件夹中的java文件进行加载,其他类型不会加载
解决方式:
方法一:
xml文件复制到target文件夹中
方法二:
通过配置文件进行配置,让maven默认加载xml文件
- pom.xml进行配置
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 --> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build> - application.properties
mybatis-plus.mapper-locations=classpath:com/atguigu/eduservice/mapper/xml/*.xml
本文来自博客园,作者:NeverLateThanBetter,转载请注明原文链接:https://www.cnblogs.com/do-it-520/p/16580064.html
韶华易逝,不能虚度年华。
浙公网安备 33010602011771号