mapperLocations’ was not specified异常的解决

项目场景:

提示:这里简述项目相关背景:

mybatis-plus自己写sql需要注意的地方。

问题描述

提示:这里描述项目中遇到的问题:

xml文件路径的问题,如果不配置,默认不会去扫描xml文件,会报Property ‘mapperLocations’ was not specified.的异常,这样你的接口访问也是拿不到数据的。


解决方案:

提示:这里填写该问题的具体解决方案:

自己写sql的话,记得配置xml文件的扫描路径。在pom文件里配置就可以了。

下面展示一些 内联代码片

            <resources>
                <resource>
                    <directory>src/main/java</directory>
                    <includes>
                        <include>**/*.xml</include>
                    </includes>
                    <filtering>true</filtering>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**.*</include>
                    </includes>

                    <filtering>true</filtering>
                </resource>
            </resources>



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
回答: 当出现Property 'mapperLocations' was not specified的提示时,可能是因为没有指定mybatis-plus的mapper文件的位置。有几种解决方案可以解决这个问题。其中一种方案是将mapper文件放在resources目录下的mapper文件夹中。这样做无需任何配置,也不会提示Property 'mapperLocations' was not specified。因为mybatis-plus的mapper-locations的默认值就是classpath*:/mapper/**/*.xml。\[1\]另一种方案是将mapper文件放在与UserMapper的包目录下,并在application.yml中添加配置mapper-locations: classpath*:com/jiguangchao/mybatisplus_01_quickstart/mapper/**/*.xml。这样做可以遵循maven项目规定,程序不会报错。但是如果不添加mapper-locations配置就会提示Property 'mapperLocations' was not specified。\[2\]此外,即使出现Property 'mapperLocations' was not specified的提示,可能不会影响项目的运行。这可能是因为mybatis-plus有默认的mapper文件位置配置。\[3\] #### 引用[.reference_title] - *1* *2* *3* [springboot项目使用mybatis-plus 时出现 Property ‘mapperLocations‘ was not specified的3个解决方案](https://blog.csdn.net/oqqZhe1234/article/details/131060542)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值