天天看点

《spring boot 集成mybatis 出现Invalid bound statement (not found)错误》 

spring boot 集成mybatis的时候出现了如下错误:

Invalid bound statement (not found)

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):XXXXXXXXXXXXXXX
........................................
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): XXXXXXXXXXXXXXXXXXXXXXXXX
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225)
           

 出错的原因是没有找到配置文件。

可能的原因是:

1.spring boot的application.properties配置文件中mybatis.config-locations及mybatis.mapper-locations的值配置错了。

2.本身的Mapper文件错了。

我检查了下自己的程序,发现是我自己的配置文件错了。接口文件原名为XXXDao,后来为了规范改为IXXXDao,但是配置文件<resultMap>中属性值type没有改过来,所以找不到配置文件。