一、报错信息
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atguigu.eduservice.mapper.EduCourseMapper.getPublishCourseInfo
at com.baomidou.mybatisplus.core.override.PageMapperMethod$SqlCommand.(PageMapperMethod.java:261)
二、报错原因
编译后mapper中没有xml文件:
当项目中创建mapper接口,编写xml文件SQL语句时候找不到文件,就会报.binding.BindingException:绑定异常错误,这个错误是maven默认加载机制造成的。
三、解决方式
1、复制xml到target目录中
2、把xml文件放到resources目录中
3、推荐使用:通过配置实现
(1)pom.xml
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
(2)项目application.properties
#配置mapper xml文件的路径
mybatis-plus.mapper-locations=classpath:com/guli/edu/mapper/xml/*.xml