使用Mybatis时报错Invalid bound statement (not found):
使用逆向工程时生成的.xml文件在conf目录下,而使用查询方法时,无法在dao包下找到xml文件,所以报错。
测试代码如下所示:
@Test
public void testSimple() throws IOException{
SqlSessionFactory sqlSessionFactory = getSqlSessionFactory();
SqlSession openSession = sqlSessionFactory.openSession();
try{ EmployeeMapper mapper = openSession.getMapper(EmployeeMapper.class);
List<Employee> list = mapper.selectByExample(null); for(Employee employee : list){
System.out.println(employee.getdId());
} }finally{
openSession.close();
}
}
报错信息如下所示:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atguigu.mybatis.dao.EmployeeMapper.selectByExample
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:223)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy6.selectByExample(Unknown Source)
at com.atguigu.mybatis.test.MyBatisTest.testSimple(MyBatisTest.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
解决办法就是找到自动生成的xml文件,并把它们复制到dao包下。
使用Mybatis时报错Invalid bound statement (not found):的更多相关文章
- 解决Mybatis 报错Invalid bound statement (not found)
解决Mybatis 报错Invalid bound statement (not found) 出现此错误的原因 1.xml文件不存在 2.xml文件和mapper没有映射上 namespace指定映 ...
- springboot+mybatis报错Invalid bound statement (not found)
今天做项目时报了一个错提示说Invalid bound statement (not found),也就是说mapper接口绑定.xml文件出错了,找不到指定的sql:原因是程序没有把.xml文件编译 ...
- MybatisPlus报错Invalid bound statement (not found)的解决方案
今天使用MybatisPlus,测试时报错Invalid bound statement (not found) 使用自定义的mapper接口中的方法可以执行,而调用MybatisPlus中baseM ...
- [mybatis] mybatis错误:Invalid bound statement (not found)
点击菜单抛出异常: org.springframework.web.util.NestedServletException: Request processing failed; nested exc ...
- mybatis 异常处理:Invalid bound statement (not found)
mybatis 的使用过程中提示错误: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): ...
- MyBatis绑定错误[Invalid bound statement (not found)]
如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...
- MyBatis 错误:Invalid bound statement (not found)
错误: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.zr.msgg.per ...
- MyBatis笔记:invalid bound statement (not found)
maven项目在本地运行的时候没有问题,一旦把war包部署到测试机上就不能运行.查看了一下tomcat日志发现抛出这样的错误:invalid bound statement (not found),后 ...
- IDEA maven项目下测试mybatis例子,使用mappper class或package引入mapper映射文件,总是报错Invalid bound statement(所有配置完全正确)
困扰几个小时,终于查到解决办法及原因(可以直接到最后看解决方案) 环境就是用IDEA搭建的maven项目,主要jar包引入配置如下 <dependencies> <dependenc ...
随机推荐
- Kubernetes资源创建yml语法
前言 在是用kubernetes中,我们对资源的创建大部分都是通过 1 kubelet create -f RESOURCE.yaml 刚开看的时候不免有一些迷茫,看不懂语法,不知道怎么写:今天本文就 ...
- 找不到Microsoft Access Driver(*.mdb)ODBC驱动程序的安装例程。请重新安装驱动
按照教材创建的方法:“控制面板-管理工具-数据源(ODBC)”,打开“ODBC数据源管理器”窗口,然后“添加”,打开“创建新数据源”的窗口,最后选择Microsoft Access Driver(*. ...
- SpringMVC 返回的 json 中去除某些不必要的属性
修改返回的Model,在对应的属性的get方法上使用 com.fasterxml.jackson.annotation.JsonIgnore 注解即可. 如 @JsonIgnore(true) pub ...
- python线程池/进程池创建
进程池 import time from concurrent.futures import ProcessPoolExecutor def task(arg): time.sleep(2) prin ...
- Django的模型层(1)- 单表操作(上)
一.ORM简介 MTV或者MTV框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的 ...
- Feature Pyramid Networks for Object Detection
Feature Pyramid Networks for Object Detection 特征金字塔网络用于目标检测 论文地址:https://arxiv.org/pdf/1612.03144.pd ...
- Android开发中string.xml文件的使用
为什么需要把应用中出现的文字单独存放在string.xml文中呢? 一:是为了国际化,Android建议将在屏幕上显示的文字定义在strings.xml中,如果今后需要进行国际化,比如我们开发的应用本 ...
- MySQL 表操作 (Day40)
阅读目录 一.表介绍 二.创建表 三.查看表 四.修改表 五.删除表 六.操作表中的记录 一.表介绍 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,则称为表 ...
- python并发编程之IO模型(Day38)
一.IO模型介绍 为了更好的学习IO模型,可以先看同步,异步,阻塞,非阻塞 http://www.cnblogs.com/linhaifeng/articles/7430066.html#_label ...
- Python函数加工厂-装饰器
引言: 函数和装饰器好比程序界的加工厂: 1.函数一般可用来加工一种或者多种数据类型的数据:字符串.数字.列表.字典等 举一个简单例子:已知半径求面积 def s(r): s = 3.14 * r * ...