• Mybatis笔记二:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)


    错误异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.dao.NarCodeMapper.getNarCode

    出现这个原因:Mybatis的Mapper interface和xml文件的定义对应不上

    大致通过如下几步来检查:

    1.Mapper interface(接口)名称和Mapper xml名称是否保持一致

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration
      PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
      <mappers>
        <mapper resource="com/test/xml/NarCodeMapper.xml"/>
      </mappers>
    </configuration>

     -----------------------------------------------------------

    package com.test.dao;

    public interface NarCodeMapper {
     
    }

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    2.Mapper xml中namespace属性值是否和Mapper interface(接口)所在(package名称+接口名称)保持一致。(本人就是在这里大意)

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    <mapper namespace="com.test.dao.NarCodeMapper">

    </mapper>

    -----------------------------------------------------------

    package com.test.dao;

    public interface NarCodeMapper {
     
    }

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    3.Mapper interface(接口)中的函数是否与Mapper xml中(select,update,insert,delete)标签中的id属性值对应

    4.去掉xml文件中文注释

    5.随意在xml文件中加一个空格或者空行然后保存

  • 相关阅读:
    MQTT
    群晖搭建webssh
    OSI 协议
    centos7 yum安装ffmpeg,以及ffmpeg的简单用法
    centos7 RTMP直播服务器搭建
    elasticsearch
    H5的storage
    bootstrap 列表組
    eclipse的debug模式下启动不了tomcat
    bootstrap collapse
  • 原文地址:https://www.cnblogs.com/sishang/p/6551151.html
Copyright © 2020-2023  润新知