天天看点

Mybatis之错误:Invalid bound statement (not found)

今天在使用Mybatis接口时遇到一个疑惑问题:

Invalid bound statement (not found):com.molly.mapper.xxx.selectByPrimaryKey

1.首先排查.xml文件的namespace,没错误

2.排查mapper接口里的方法名字,没错

换了个方法发现同样是无效的,那肯定是文件没有读到喽

于是查看文件有什么问题,发现在创建xml的时候,以往是通过new file:输入xxx.xml创建的,此次再输入文件名之后让选择类型,于是我选了下图的类型

Mybatis之错误:Invalid bound statement (not found)

于是我创建的xml和以往有所不同

Mybatis之错误:Invalid bound statement (not found)

所以我的Mapper.xml并没有读取到,虽然我不知道这两种方式有什么区别,但是这个错误真够无语的…