Invalid bound statement (not found): com.atguigu.auth.mapper.SysMenuMapper.findMenuListByUserId报错

文章介绍了SpringBoot项目中遇到MybatisXML配置文件无法加载的两种原因,一是namespace路径错误,二是XML文件不在resources包下。提供的解决方案包括将XML文件移至resources目录或在pom.xml中配置加载java包下的xml文件,并在application.yml中指定mapper的路径。
摘要由CSDN通过智能技术生成

该报错有两种原因:

1.mybatis文件中的xml配置文件中namespace路径写错,找不到文件

2.由于springboot项目在src.main.java包下只能读取到java后缀的文件,mybatis中的xml文件是加载不了的,可以通过target编译包下查看是否加载了xml文件

解决方案

方法一

将xml文件复制到resources包下,重新编译

方法二

2.1.在pom.xml文件中加入以下代码,用于加载src/main/java包下的xml文件

   <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes> <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

2.2.在application.yml文件中扫描mapper包下的xml文件

mybatis-plus:
  mapper-locations: classpath:com/backcat/auth/mapper/xml/*.xml

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值