在做spring+mybatiss时,自动扫描都配置正确了,却在运行时出现了如下错误。后来查看target/classes/.../dao/文件夹下,发现只有mapper的class文件,而没有xml文件,将对应的xml文件放到这个文件夹下运行就不会出现下面的错误。说明出现这个错误的原因是maven编译时没有将xml文件放进去。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.cnblogs.hellomsg.fileupload.dao.UploadFileMapper.getFileWithHashCode
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
at com.sun.proxy.$Proxy12.getFileWithHashCode(Unknown Source)
at com.cnblogs.hellomsg.fileupload.service.impl.UploadFileServiceImpl.getFileWithHashCode(UploadFileServiceImpl.java:31)
at com.cnblogs.hellomsg.test.TestMybatis.test1(TestMybatis.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

解决方法:

在pom.xml中添加如下代码:

<build>
...
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
...
</build>

最新文章

  1. WPF学习笔记1---初接触
  2. UVA1103
  3. 作业七:团队项目——Alpha版本冲刺阶段-12
  4. 会话控制:session与cookie
  5. SQL Server数据库表重置自增主键号(通常是指ID)
  6. [转]CodeSmith和PowerDesigner的使用安装和数据库创建
  7. JAVA项目JDK版本修改
  8. simple python code when @ simplnano
  9. Android HttpClient GET或者POST请求基本使用方法(转)
  10. SCOI2014 方伯伯的OJ onlinejudge
  11. CreateFile FileSeek FileRead 直接读取数据
  12. Oracle EBS-SQL (SYS-23):用户权限查询.sql
  13. C#实现文档转换成PDF
  14. vim编辑器设置文件的fileformat
  15. elasticsearch 索引 red 状态恢复 green
  16. JAVA基础第八组(5道题)
  17. 4. 跟踪标记 (Trace Flag) 610 对索引组织表(IOT)最小化日志
  18. WPF自学入门(十)WPF MVVM简单介绍
  19. 第二单元电梯调度作业 By Wazaki
  20. spark教程

热门文章

  1. android自定义控件(一) 官方文档的翻译
  2. OpenCV——PS 滤镜算法之平面坐标到极坐标的变换
  3. Ubuntu 16.04上编译SkyEye的测试程序
  4. Sox语音转换的相关知识
  5. BZOJ-3940:Censoring(AC自动机裸题)
  6. 物联网项目开发必读 深度分析MQTT协议优缺点
  7. 事务之六:spring 嵌套事务
  8. 安装时后的idea,项目不能运行,pom.xml文件不能下载到本地仓库,maven配置是正确的
  9. python--环境变量的使用
  10. hadoop学习路线(转)