zoukankan      html  css  js  c++  java
  • Invalid bound statement (not found): com.xxx.xxx.dao.ShopMapper.insertShop

    mybatis在编写完SQL,进行测试的时候出现了错误,显示

    org.apache.ibatis.binding.BindingException: Invalid bound statement
    (not found): cn.edu.nyist.dao.ShopMapper.updateShop
    在这里插入图片描述

    当时在确认shopMapper.xml中的insert语句没有错误后,开始在网上找到了解决方法,首先确认Mapper.xml文件的位置,在maven搭建的项目中,如果Mapper.xml在resources目录下记得你所编写的xml文件名要和dao接口名一致,并在pom.xml后面添加以下标签

    <build>
            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <!-- 此配置不可缺,否则mybatis的Mapper.xml将会丢失 -->
                    <includes>
                        <include>**/*.xml</include>
                    </includes>
                </resource>
                <!--指定资源的位置-->
                <resource>
                    <directory>../mybatis02/src/main/resources/resources</directory>
                </resource>
            </resources>
        </build>
    
    

    还有一种不需要在pom.xml中添加,但是你所创建的mapper.xml和dao接口需要在一个包下,并且必须同名。
    在这里插入图片描述
    第三、也是我这次没有注意到的一点,Mapper.xml文件的namespace必须和你想实现的接口对应。也就是说namespace的值一定要正确。
    在这里插入图片描述
    本来这里实现的是ShopMapper。唉,当时Crtl+A,crtl+c,crtl+v…竟然忘记修改了,真是大意了!
    改正确后,就能正常测试了!为防止以后再犯,特此记录一下!

  • 相关阅读:
    使用 libevent 和 libev 提高网络应用性能
    An existing connection was forcibly closed by the remote host
    各种浏览器的兼容css
    vs输出窗口,显示build的时间
    sass
    网站设置404错误页
    List of content management systems
    css footer not displaying at the bottom of the page
    强制刷新css
    sp_executesql invalid object name
  • 原文地址:https://www.cnblogs.com/dataoblogs/p/14121973.html
Copyright © 2011-2022 走看看