Maven项目mybatis Invalid bound statement (not found)解决方法
2018-03-09 12:07
429 查看
最近因为工作需要,要学习mybatis框架。在添加好一些依赖之后,通过mybatis进行数据库的crud操作。但是在测试的时候总是报mybatis:Invalid bound statement (not found)。在网上搜索了好久,最后终于发现了问题的所在,现在把它记录下来,供大家参考:在mapper代理的开发中,程序员需要遵守一些规范,mybatis才能实现mapper接口的代理对象。
它的规范如下:mapper.xml的namespace要写所映射接口的全称类名。
mapper.xml中的每个statement的id要和接口方法的方法名相同
mapper.xml中定义的每个sql的parameterType要和接口方法的形参类型相同
mapper.xml中定义的每个sql的resultType要和接口方法的返回值的类型相同
mapper.xml要和对应的mapper接口在同一个包下
mapper.xml的命名规范遵守: 接口名+Mapper.xml
如果以上检查完毕,项目都遵守了上述的规范,而且你的项目是Maven项目。但是运行程序还是会出现Mybatis invalid bound statement(not found)的问题,这个时候就需要修改pom.xml文件了。在pom.xml中添加如下的代码:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
将以上代码添加到pom.xml中,运行项目,问题解决。
它的规范如下:mapper.xml的namespace要写所映射接口的全称类名。
mapper.xml中的每个statement的id要和接口方法的方法名相同
mapper.xml中定义的每个sql的parameterType要和接口方法的形参类型相同
mapper.xml中定义的每个sql的resultType要和接口方法的返回值的类型相同
mapper.xml要和对应的mapper接口在同一个包下
mapper.xml的命名规范遵守: 接口名+Mapper.xml
如果以上检查完毕,项目都遵守了上述的规范,而且你的项目是Maven项目。但是运行程序还是会出现Mybatis invalid bound statement(not found)的问题,这个时候就需要修改pom.xml文件了。在pom.xml中添加如下的代码:
<build> <resources> <resource> <directory>src/main/java</directory> <!-- 此配置不可缺,否则mybatis的Mapper.xml将会丢失 --> <includes> <include>**/*.xml</include> </includes> </resource> <!--指定资源的位置--> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
将以上代码添加到pom.xml中,运行项目,问题解决。
相关文章推荐
- Maven项目mybatis Invalid bound statement (not found)解决方法
- maven + mybatis Invalid bound statement (not found) 错误解决
- IDEA的maven项目出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- IDEA中 Invalid bound statement (not found)解决方法
- IDEA中 Invalid bound statement (not found)解决方法
- MyBatis绑定错误提示BindingException:Invalid bound statement (not found)的解决方法
- springmvc+mybatis 诡异问题 Invalid bound statement (not found)
- mybatis invalid bound statement (not found) : com.XXXX
- Mybatis——Invalid bound statement (not found)-Could not find result map java.lang.Integer
- invalid bound statement (not found)解决办法
- invalid bound statement (not found)解决办法
- maven 编译mybatis项目时xml文件无法编译到target目录下的解决方法
- springboot 集成mybatis Invalid bound statement (not found)异常
- mybatis Invalid bound statement (not found)
- 解决maven项目不会预读xml文件,Invalid bound statement (not found): com.starry.dao.IUserDao.selAll
- maven导入项目时出现“Cannot read lifecycle mapping metadata …… invalid END header (bad central directory offset)pom”错误的解决方法
- Mybatis Invalid bound statement (not found)问题分析
- 【问题解决】Maven搭建Web项目中org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问
- spring boot mybatis Invalid bound statement (not found)