首页 > 其他分享 >springboot项目报错找不到mapper文件

springboot项目报错找不到mapper文件

时间:2023-07-23 14:33:33浏览次数:30  
标签:xml mapper springboot 文件 Plus MyBatis 报错

在使用 SpringBoot 中的 MyBatis-Plus(简称 MP)时,出现无法找到 mapper.xml 文件的错误,可能有以下几个原因:
1.未正确配置 mapper.xml 文件路径:在 SpringBoot 中,可以通过在 application.properties 或 application.yml 文件中设置 mybatis-plus.mapper-locations 属性来指定 mapper.xml 文件的位置。如果该属性没有设置或设置错误,MyBatis-Plus 将无法找到 mapper.xml 文件,导致报错。

2.mapper.xml 文件没有放置在正确的位置:在 MyBatis-Plus 中,默认情况下会将 mapper.xml 文件放置在 resources/mapper 目录下。如果 mapper.xml 文件没有放置在该目录下,MyBatis-Plus 将无法找到 mapper.xml 文件,导致报错。

3.mapper.xml 文件没有被正确加载:在 SpringBoot 中,可以使用 MyBatis-Plus 提供的 MapperScannerConfigurer 注解来扫描 mapper 接口,并将其注册到 Spring 容器中。如果没有正确配置该注解,或者 mapper 接口没有被正确注册到 Spring 容器中,MyBatis-Plus 将无法找到 mapper.xml 文件,导致报错。

4.MyBatis-Plus 版本过低:在较早版本的 MyBatis-Plus 中,可能存在无法识别 mapper.xml 文件的 bug,导致报错。此时,可以尝试升级 MyBatis-Plus 版本,或者将 mapper.xml 文件转换为注解形式的 SQL 语句。

标签:xml,mapper,springboot,文件,Plus,MyBatis,报错
From: https://www.cnblogs.com/liwenfeng/p/17574968.html

相关文章

  • springboot启动依赖冲突(log4j2)
    报错示例:LoggerFactoryisnotaLogbackLoggerContextbutLogbackison1.解决方案:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-log4j2</artifactId><......
  • springboot项目启动找不到外部入口url怎么办?
    启动类下输出控制面板直接打印@Slf4j@SpringBootApplicationpublicclassSpringboot03Application{publicstaticvoidmain(String[]args)throwsUnknownHostException{ConfigurableApplicationContextcontext=SpringApplication.run(Springboot03App......
  • SpringBoot项目集成Mybatis Generator代码生成器
    添加依赖在项目的pom.xml文件中添加以下依赖<!--mybatisgenerator自动生成代码插件--><plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId>......
  • SpringBoot开发符合S3协议的文件存储服务
    背景公司最近的业务大量涉及安可项目,要求避免使用第三方组件,原有开发框架支持本地文件存储/Minio/各类云存储,现在要求文件独立存储且文件服务需要自研,经调研评估后决定基于SpringBoot开发文件存储服务,使用s3协议标准,这样可以直接使用aws-sdk接入无需再开发客户端,且安全安全性方面......
  • SpringBoot 自动装载 Bean
    我们在工作中经常会遇到这样的场景,我们写了很多非常实用的工具类,这些类在多个项目工程中使用非常频繁。如果在每个要使用的项目工程中都去编写加载bean的代码的话,那么重复的代码就太多了。如果你想追求完美只写一份代码的话,使用SpringBoot的自动装载的特性是一个很不错的方案......
  • map.xml文件报The content of element type "mapper" must match "(cache-ref|cache|r
    出现这个问题 是因为  <insert></insert>  <delete></delete>  <update></update>  <select></select>等标签写的不完整或者写错位置了比如<insert></insert>只写了一个,没有写结尾</insert>或者<insert></insert>中的</in......
  • JVAA springboot 项目启动后,localhost加端口可以访问,但是外网IP不行// OCPP KYOHOON
     现象javaspringboot项目启动后,localhost(或127.0.0.1)加端口可以访问,但是使用外网IP却无法访问。   原因及解决方法springboot的配置文件(yml或properties)中缺少server.address的设置。解决方法:在springboot的配置文件中增加server.address的配置。yml配......
  • Python报错 | AttributeError: 'NoneType' object has no attribute 'group'
    报错信息使用Python正则匹配的时候,报如下错误:AttributeError:'NoneType'objecthasnoattribute'group'错误原因报错翻译过来是:属性错误:“NoneType”对象没有属性“group”没有匹配到符合正则表达式的内容,但又调用了group方法。importrestr='hellopython!!!hel......
  • infraworks卸载不干净无法安装?一招教你如何搞定infraworks安装失败报错的问题【转载】
    infraworks专用卸载工具,完全彻底卸载删除干净infraworks各种残留注册表和文件的方法和步骤。如何卸载infraworks呢?有很多同学想把infraworks卸载后重新安装,但是发现infraworks安装到一半就失败了或者显示infraworks已安装或者安装未完成,大多数情况下其实是infraworks没有被卸载干......
  • springboot整合activeMQ
    依赖<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4......