Mybatis-puls BUG集合

本文主要探讨了Spring Boot应用中遇到的Mapper扫描问题。当出现'No qualifying bean of type ‘com.tengyun.itinerary.mapper.ClasMapper’ available'错误时,解决方案是在启动类上添加@MapperScan注解指定mapper包路径。同时,如果出现'Invalid bound statement (not found)',可能是因为mapper.xml文件未被正确加载,需检查文件位置并在pom.xml中配置资源包含,或者在application.properties/yml中设置mapper的路径。确保路径正确无误,避免启动失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

No qualifying bean of type ‘com.tengyun.itinerary.mapper.ClasMapper’ available: expected at least 1 bean which qualifies as autow

没有合格的bean可用,没有扫描到mapper,需要在启动类中加入,@MapperScan(" com.test.test1.mapper ")
在这里插入图片描述

Invalid bound statement (not found): com.tengyun.itinerary.service.ClasService.pageClas

绑定语句无效,没有加载到mapper.xml文件,如果你的mapper.xml放在Java类文件夹中,需要在pom.xml中配置,放在dependencies标签外

<!-- 项目打包时会将java目录中的*.xml文件也进行打包,**多级目录 -->
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

在application.properties配置文件中,配置

#配置mapper xml文件的路径
mybatis-plus.mapper-locations=classpath:com/lsl/eduservice/mapper/xml/*.xml

yml格式

mybatis-puls:
  mapper-locations: classpath:/com/tengyun/itinerary/mapper/xml/*.xml

不要把路径写错了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值