Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
maven项目使用mybatis时,找不到mapper文件(.xml)
错误信息提示:
项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!!
错误原因:
- mybatis没有找到对应的请求调用持久层的方法
查错方法:
首先检查target-->classes文件夹被dao层文件夹内是否有对应mapper.xml文件,如果有xml文件,则一般是配置文件出现的错误,如果没有xml类型的文件,则是没有拷贝资源文件的原因。下面是对应的解决方法。
1.名称不一致问题
排查步骤:
- 检查mapper接口与mapper.xml文件名称是否一致
- mapper.xml里面指定的namespace是否是mapper接口,名称是否正确
mapper接口内的方法名时候与mapper.xml文件中的id对应
检查mybatis配置文件(SqlMapConfig.xml)与spring配置文件指定的名称是否一致
web.xml配置文件中指定的spring配置文件名称是否与真实的spring配置文件的名称路径一致
2. 默认拷贝资源文件无效的问题(target目录下的classes文件夹内没有对应的mapper.xml)---默认不拷贝src/main/java下面的配置文件
解决方案【以下三种方案选一种即可】(ecplise):
项目名--右击--build path--config build path--source--src/main/java--out.....---edit---add---**/*.xml
推荐下面方式,ecplise和idea都可使用
pom.xml文件中 添加资源文件拷贝插件 添加自定义的资源文件拷贝行为(如果配置src/main/java的拷贝行为,会导致默认的拷贝行为失效,即不再拷贝src/main/resouce文件夹内的位置文件,应该将两个都拷贝行为都配置一下)
<!-- 资源文件拷贝插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 资源文件拷贝插件 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
- 将mapper接口和mapper.xml文件分开 在resouce文件夹内模仿mapper接口文件层次创建文件夹,将mapper.xml文件放在里面,编译输出时,会输出在target目录下的同一位置
温馨提示:使用IDEA将会避免大部分问题,IDEA真香!!!
Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的更多相关文章
- maven 项目报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决
idea在使用maven构建的项目中使用mybatis时报错org.apache.ibatis.binding.BindingException: Invalid bound statement (n ...
- maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
ssm的项目如果在mapper.xml mapper接口 配置没问题的情况下 项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...
- 项目启动报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wuhongyu.mapper.OrdersMapper.selectByExample
在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件, 在 ...
- mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型
- Srping mvc mabatis 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
我的Mapper采用接口+注解的方式注入 @Repository(value="customerServOutCallMapper")public interface Custom ...
- mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- 使用maven整合mybatis时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
分析原因是mybatis的映射文件的问题,首先进行分析排查: 1.检查mapper接口和对应的xml文件的包名是否对应 2.检查xml文件的namespace与mapper接口的包名是否对应 3.检查 ...
- 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...
在IDEA中将xxxMapper.xml文件创建在(src/main/java)目录中,运行报错:org.apache.ibatis.binding.BindingException: Invalid ...
随机推荐
- 侠梦说pinpoint--左侧服务地图调用量和WasOn过滤
前言 这篇文章主要是从pinpoint-web界面入手,我们的目标是弄清楚两个问题: 1. pinpoint左侧服务地图上的调用量数据是怎么查询的? 2.界面查询条件WasOnly是什么意思? 左侧服 ...
- 【tf.keras】实现 F1 score、precision、recall 等 metric
tf.keras.metric 里面竟然没有实现 F1 score.recall.precision 等指标,一开始觉得真不可思议.但这是有原因的,这些指标在 batch-wise 上计算都没有意义, ...
- C# delegate和C# event
在基于Windows平台的程序设计中,事件(event)是一个很重要的概念.因为在几乎所有的Windows应用程序中,都会涉及大量的异步调用,比如响应点击按钮.处理Windows系统消息等,这些异步调 ...
- Vue引入
Vue引入 概念: 1.el:实例 new Vue({ el: '#app' }) // 实例与页面挂载点一一对应 // 一个页面中可以出现多个实例对应多个挂载点 // 实例只操作挂载点内部内容 2. ...
- 一个null,差点把系统给弄崩溃了
今天生产上面发现了一个奇异的bug,URL上面会带上一个ID,这个ID是关联别的系统的,类似这种格式 xxx.xxx.xxx.xxx ,是别的系统自己填写的,我们的URL会带上id=xxx.xxx. ...
- python_迭代器和生成器、字节串、字节数组
迭代器 iterator 和 生成器 generator 什么是迭代器:迭代器就是获取迭代对象中元素的工具,迭代器是由可迭代对象生成的 1.迭代器是指用iter(可迭代对象)函数返回的对象(实例) ...
- 关于SQL Server 中日期格式化若干问题
select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08 select replace(replace(replace(CONVERT(v ...
- cluster模块设置子进程的stdio
原因 子进程的stdout及stderr需要被设置为某个文件,根据文档 setupMaster 说明,需要设置stdio数组: c.setupMaster({ exec: `${cwd}/c.js`, ...
- 利用Mitmproxy抓包
http://mrpeak.cn/blog/mitmproxy/ 和Charles同样强大的免费抓包软件. 它是在终端操作的,界面没有Charles那么可视化.不过也很好用,通过各种快捷键操作,效 ...
- CodeForces-Round235D
链接:http://codeforces.com/contest/401/problem/D 题意:给出一个数字num和m,问通过重新排列num中的各位数字中有多少个数(mod m)=0,直接枚举 ...