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
    

    重启项目,解决。

  • 相关阅读:
    pytorch常用函数
    检测(2):开始训练
    gcc的替换,很有用
    detection-pytorch环境配置的遇到的坑
    一些有用的ubuntu命令总结---长期更新
    如何用gdb工具进行调试
    检测(1)从0到1
    检测
    pytorch遇到的问题---不定期更新
    假名快速记忆
  • 原文地址:https://www.cnblogs.com/dataoblogs/p/14121836.html
Copyright © 2011-2022 走看看