zoukankan      html  css  js  c++  java
  • org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    出现异常:

    AbstractHandlerExceptionResolver.java:194 |org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver |Resolved exception caused by handler execution: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.online.edu.mapper.CourseMapper.getCoursePublishVoById

    分析问题

    经过查找与判断不是SQL语句的问题,而是配置文件没有加载到。

    dao层编译后只有class文件,没有mapper.xml,因为maven工程在默认情况下src/main/java目录下的所有资源文件是不发布到target目录下的,只有resources目录下的配置文件可以被编译到class中。

    解决方案

    第一种

    手动改变项目文件结构,也就是将mapper目录下的xml文件放到resources目录下。但是这种改变项目结构的方法不推荐。

    第二种

    在该项目的pom.xml文件中添加以下配置。

    <!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>
    

    同时在application.properties/application.yml中添加mapper下xml文件的扫描路径。

    #配置mapper xml文件的路径
    mybatis-plus.mapper-locations=classpath:com/online/edu/mapper/xml/*.xml
    

    重启项目,解决。

  • 相关阅读:
    原型设计工具 SketchFlow
    Vs2010架构设计层图(Layer Diagram)
    javascript in Visual Studio
    COM应用总结补充【COM+】
    WMI介绍、WQL
    Windows Azure Platform AppFabric 3/3
    Windows脚本 实例 3/4
    Silverlight Training
    一个很好的sliverlight站点
    建模形式构建Zend Framework应用
  • 原文地址:https://www.cnblogs.com/dataoblogs/p/14121836.html
Copyright © 2011-2022 走看看