美文网首页
Mybatis:老是出现Invalid bound statem

Mybatis:老是出现Invalid bound statem

作者: 靗鲭 | 来源:发表于2020-12-28 13:42 被阅读0次

更新:一段时间没用idea搭建项目了,现在再次搭建SSM时又反复报Invalid bound statement (not found)。现记录一下,拍打下我的记忆力,让我看问题再仔细一点。

一、添加pom依赖

如果像这样在java里(而不是resources)的同个dao包里放置mapper.xml和接口的话,要在pom的build里再加上如下代码:
<!-- idea默认只扫描resources里的xml文件,Mapper.xml文件放在src里,要加这句resources才能编译出来
                而且,必须放在plugins的下面,否则不生效-->
<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.xml</include>
        </includes>
        <filtering>true</filtering>
    </resource>
 </resources>

https://blog.csdn.net/someby/article/details/96473263

二、修改application

mybatis.mapper-locations=classpath*:com/example/项目名/dao/mapper/*.xml
配置

三、添加java类里的注解

大致目录如下:

1. controller
2. dao接口
3. 接口service的实现类

四、mapper.xml文件

mapper.xml



相关文章

网友评论

      本文标题:Mybatis:老是出现Invalid bound statem

      本文链接:https://www.haomeiwen.com/subject/bugznktx.html