解决Invalid bound statement (not found)(Mybatis的Mapper绑定问题)
2023-09-11 14:16:37 时间
测试:报告异常
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目录下的,
![](https://img2020.cnblogs.com/blog/2174081/202107/2174081-20210725215554935-2038045316.png)
解决方案:
出现这个错误时,按以下步骤检查一般就会解决问题: 1:检查xml文件所在package名称是否和Mapper interface所在的包名一一对应; 2:检查xml的namespace是否和xml文件的package名称一一对应; 3:检查方法名称是否对应; 4:去除xml文件中的中文注释; 5:随意在xml文件中加一个空格或者空行然后保存。
![](https://img2020.cnblogs.com/blog/2174081/202107/2174081-20210725215714684-1805323060.png)
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
相关文章
- Wrong detect of Parsing error: invalid-first-character-of-tag-name in expression.
- kentico中提示Message: An invalid SQL query was used.
- Google Earth Engine(GEE)——export影像导出错误Error: Image.clipToBoundsAndScale, argument ‘input‘: Invalid
- python关于error: invalid command 'bdist_wheel报错的解决
- C++释放指针时提示Invalid address specified to RtlFreeHeap解决办法(堆栈中分配时多分配一些空间再释放)
- QQ connect client request's parameters are invalid, invalid openid 问题的解决
- Invalid utf8mb4 character string: '"'
- STM32F10x烧写代码出现invalid rom table
- mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置
- Steps to Resolve the Database JAVAVM Component if it Becomes INVALID After Applying an OJVM Patch
- mybatis 异常处理:Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mysql数据库中不能插入0000-00-00 00:00:00日期数据(报错Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00')
- SpringBoot+Mybatis+mybatis generate+oracle
- 【转】Mybatis学习---MyBatis知识、原始Dao开发和mapper代理开发
- delphi vlc 安装bug 处理编译错误"0" is an invalid value for the "DebugInformation" parameter of the "DCC"
- Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your datab
- Mybatis+Oracle搭配insert空值报错之myBatis+mysql驱动+oracle驱动的源码分析
- spring,配置文件applictionContext.xml,Mybatis mybatis.xml,springMVC spring整合springMVC mybatis