Invalid bound statement (not found): 各种原因
这个问题出现在用xml配置mybatis的mapper时:
各种可能原因有:
**1.你的mapper写在了java目录里面。*例如下图:这样会出现一个问题,即使你在properties里面配置了 mybatis.mapper-locations= classpath:com/lihaoyu/demo/dao/*.xml,也没有用,因为编译的时候这个xml文件并没有被自动拉到target里面,毕竟编译的是.java文件而不是xml嘛,所以这时候应该在pom文件里面加上:
</build>
<resources>
<resource>
<directory>src/main/java</directory><!--所在的目录-->
<includes><!--包括目录下的.properties,.xml文件都会扫描到-->
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
如果你把xml放到了resources文件下,那么就只需要配置mybatis.mapper-locations=classpath*:mapper/*.xml 就可以了,因为构建的时候会把resources里的东西自动拉到classpath***意.classpath意思就是编译后target文件夹下的classes目录.
2.xml里面的namespace不对 或者id和mapper里面的方法名不一样,或者parameterType对应不上,都会出现这种问题。