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