springboot整合mybatis提示nvalid bound statement (not found)错误解决方案

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27298687/article/details/88115737

最近在进行springboot和mybatis整合的时候发现项目能正常启动,但在请求数据时却一直提示nvalid bound statement (not found),在网上查了很多资料,都没能解决。如果使用的是IDEA,都是说没在配置文件中添加

#mybatis.typeAliasesPackage=com.sgcc.uap.dao
#mybatis.mapperLocations=classpath:mapper/*.xml

或者是没在mapper接口中添加@Mapper注解,我一一排查后发现都不是。最后在一片博文里看到了解决方案

1.主要问题出在dao层,有人喜欢将包名写成dao,也有人在使用mybatis时习惯写成mapper,这两者本身并没有什么问题。

2.解决方案,我们需要将我们的dao接口或mapper接口类名写成和xml文件名称一致,这样就能成功加载mapper.xml文件了,可能springboot默认是基于这种规则来寻找的。

猜你喜欢

转载自blog.csdn.net/qq_27298687/article/details/88115737