解决Invalid bound statement (not found)(Mybatis的Mapper绑定问题)
测试:报告异常
AbstractHandlerExceptionResolver.java:194 |org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver |Resolved exception caused by handler execution: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.guli.edu.mapper.CourseMapper.getCoursePublishVoById
问题分析:
dao层编译后只有class文件,没有mapper.xml,因为maven工程在默认情况下src/main/java目录下的所有资源文件是不发布到target目录下的,

解决方案:
出现这个错误时,按以下步骤检查一般就会解决问题: 1:检查xml文件所在package名称是否和Mapper interface所在的包名一一对应; 2:检查xml的namespace是否和xml文件的package名称一一对应; 3:检查方法名称是否对应; 4:去除xml文件中的中文注释; 5:随意在xml文件中加一个空格或者空行然后保存。
1、在pom中配置如下节点
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
重新打包项目会发现target目录下出现了xml文件夹

2、在Spring Boot配置文件中添加配置
#配置mapper xml文件的路径 mybatis-plus.mapper-locations=classpath:com/guli/edu/mapper/xml/*.xml

浙公网安备 33010602011771号