Mybatis Plus 自定义 SQL 无法执行
问题描述:指在 XML 中里面自定义 SQL,却无法调用。本功能同
MyBatis
一样需要配置 XML 扫描路径:
1 | org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.likfees.mapper.EmployeeMapper.getByUsername |
- Spring Boot 配置(参考mybatisplus-spring-boot (opens new window))
1 | mybatis-plus: |
对于
IDEA
系列编辑器,XML 文件是不能放在 java 文件夹中的,IDEA 默认不会编译源码文件夹中的 XML 文件,可以参照以下方式解决:方式一:将配置文件放在 resource 文件夹中
方式二:对于 Maven 项目,可指定 POM 文件的 resource
1
2
3
4
5
6
7
8<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>提示:注意!Maven 多模块项目的扫描路径需以
classpath*:
开头 (即加载多个 jar 包下的 XML 文件)
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment