Invalid bound statement (not found) / Failed to execute goal org.apache.maven.plugins:maven-suref

spring boot与mybatis-plus集成出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
即 --> 绑定异常:无效的绑定语句(未找到)

—原因有几个方面:
1:xml文件里面的namespace对应的mapper接口路径是否正确。

<mapper namespace="com.dengqing.mapper.UserMapper">

2:Mapper接口里面的方法(findUserByUserId)是否对应xml里面的id=“findUserByUserId”,这里最好复制,不要全部手敲
3: 查看配置文件,自己配置的规则是否遵循
application.yml配置(application.properties同理,只是细节不一样):

mybatis-plus:
  mapper-locations: classpath:com/dengqing/hahah/*.xml
  type-aliases-package: com.dengqing.entity

pom.xml 配置:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            
            <!--      maven执行clean install或者install 出现问题:
            Failed to execute goal org.apache.maven.plugins:maven-surefire-       plugin:2.22.2:test (default-test)on project demo: There are test failures.  
            添加下列<plugin/>     -->
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
        <!--解决org.apache.ibatis.binding.BindingException: Invalid bound statement -->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

我的定义的xml文件在/hahah包下面,但是接口在mapper包下面
如图
在这里插入图片描述所以xml和持久层接口没有太强的关联关系,看你自己的配置而定,我的UserRoleMapper.xml和TUserMapper接口名称不相同、路径不相同一样可以调用。

原因3是重点,配置好了才能根据配置的规则使用,原因1、2是细节处理。**

如果有 spring boot与mybatis-plus(mybatis)集成问题的话,可以留言私我,后续的话我会将spring boot与mybatis-plus、shiro集成的上传到gitee。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值