MyBatis报错Invalid bound statement (not found)

这种报错有很多可能

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错误的!,其原因就是简单的路径不对,但是却很难发现

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值