• Maven项目编译后classes文件中没有.xml问题


    在做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>
    复制代码
  • 相关阅读:
    call/cc 总结 | Scheme
    用call/cc合成所有的控制流结构
    词法作用域 vs 动态作用域
    数论部分第二节:埃拉托斯特尼筛法
    1022: [SHOI2008]小约翰的游戏John【Nim博弈,新生必做的水题】
    C++面向对象作业1
    数论部分第一节:素数与素性测试【详解】
    基数排序与桶排序,计数排序【详解】
    计蒜客:百度的科学计算器(简单)【python神解】
    优质免费在线学习网站【自用】
  • 原文地址:https://www.cnblogs.com/winkey4986/p/6924458.html
Copyright © 2020-2023  润新知