这种报错有很多可能
1. mapper方法等名称写错
自己修改即可
2. mvn打包时没有加入xml文件
<!--
IDEA需要添加一下内容,否则无法找到mapper
-->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/web/dal/*/mapper/*Mapper.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
如果在mybatis的xml配置无误情况下,还出现Invalid bound statement (not found) ,那么就在当前模块的pom.xml中添加此段代码。
3. 在SpringBoot下的问题(网上没找到有类似情况)
mapper的xml文件是放在response/mapper下的,然后在application.yml里配置Mybatis-plus:
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
typeAliasesPackage: com.lvjian.jiyu.entity
global-config:
id-type: 0
db-column-underline: true
refresh-mapper: true
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
注意 mapper-locations的设置,如果是classpath:/mapper/*.xml的话,也会出现Invalid bound statement错误的!,其原因就是简单的路径不对,但是却很难发现