天天看點

BindingException: Invalid bound statement (not found)

mybatis中dao接口與mapper配置檔案映射綁定失敗,即dao層接口與xml檔案方法比對不到。

BindingException: Invalid bound statement (not found)

 常見原因可能有:

1. mapper.xml的namespace是否對應接口類的全名,必須完全一緻。

namespace="com.blog.dao.mapper.ArticleMapper"      

2.  mapper接口類的方法名是否與mapper.xml中sql标簽的id相同

3. 當方法的傳回值是resultMap時,需要使用resultMap,而不用resultType

<select id="listArticle" resultMap="articleMap">
        select * from ms_article
</select>      

4. 檢視mapper的XML配置路徑是否正确,否則掃描不到mapper類

非常有可能是你不小心寫錯了一個字母。但是以上方法我都試過了都沒有解決,最後發現我報異常的原因是我的mapper接口類和mapper.xml包名不一緻

BindingException: Invalid bound statement (not found)