spring boot 項目使用 Mybatis-plus 時出現錯誤,下面是具體的報錯信息:
翻譯一下報錯:
org.apache.ibatis.binding.bindingException: 綁定語句無效(未找到)
也就是在 mybatis-pous 中 mapper 層 xxxMapper 接口與 xxxMapper.xml 文件在做映射綁定的時候出現問題,也就是 xxxMapper 接口無法匹配到操作sql語句的方法 id
解決:
1.檢查 xml 映射文件中 <mapper> 標簽綁定包名地址是否正確(即 namespace 的值)
2. 檢查 xxxMapper 接口中的方法,對應xml映射文件中是否有,xml 中的 id 必須和 mapper 文件的接口名稱一致
3.檢查 <select> 標簽中的 resultType 是否與 xxxMapper 接口中的方法返回值類型一致,若一個是對象一個是集合,那也會報錯
4.檢查 yml 配置文件中的 mybatis-plus 配置
我的項目結構:
application.yml 文件配置:
(ps:使用 mybatis-plus 配置文件不要用成 mybatis 的)