【问题解决】Maven搭建Web项目中org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问
来源:互联网 发布:中投证券交易软件 编辑:程序博客网 时间:2024/06/02 06:10
最近使用Maven配合SSM(Spring+SpringMVC+Mybatis)搭建一个Web项目,在测试三个框架是否整合成功的时候,每次发出请求调用MyBatis时都会出现下面这个错误
从异常信息的提示来看是一个无效的语句绑定错误,一般出现该错误是由于MyBatis的Mapper映射的xml文件丢失或者没配置好,于是检测自己的映射文件
发现自己的配置文件存在,而且xml的书写也没问题,于是推测问题可能出在当使用Maven运行项目时项目中生成的目标的文件都会在target文件夹下,而且web项目的运行正是依靠于target文件下的这些class文件,Mapper映射接口的class文件要想正确运行则在target目录下必须也存在对应的Mapper映射的XML文件。检查自己的target目录下对应文件夹果真是由于缺少Mapper接口的XML配置文件造成的问题,下面进行解决
解决办法:
方法一:只需要将XML文件复制到target文件下相应目录即可解决上面出现的BindingException。
方法二:方法一是一种治标不治本的解决方案,之所以这样说是由于当我们修改了Mapper的XML文件的内容重新运行项目时又需要手工的将修改的文件复制再次复制过去,相当的麻烦,当项目中XML较多时这个方法完全不合理。经过查阅相关资料,我们可以把拷贝XML文件的这件事交给Maven来替我们做,只需要在Mavaen项目中Mapper对应的子工程的pom.xml文件中添加以下配置即可
<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --><build><resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources></build>
添加完成后,测试成功。
8 0
- 【问题解决】Maven搭建Web项目中org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问
- maven项目中,遇到org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- SSMF maven项目 mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found
- 运行Maven项目:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- maven 项目,mybatis报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Qt文件读写操作
- git安装与使用
- 根据地址获取HTTP返回的状态码
- 判断UITextField文本输入框的输入长度
- [IMX6DL]超声波模块KS103 Linux驱动源代码
- 【问题解决】Maven搭建Web项目中org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问
- hdu 5660 暴力枚举
- iOS常见问题
- SVN命令使用
- 最大连续子数组和
- Activity(一)—生命周期及启动模式
- maven的入门与测试
- 客户端-服务器模式(架构)
- postgres函数和操作符