更新:一段时间没用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>

二、修改application

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

三、添加java类里的注解
大致目录如下:

1. controller

2. dao接口

3. 接口service的实现类

四、mapper.xml文件

网友评论