欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

mybatis-plus的 mapper.xml 路径配置的坑

发布时间:2024/9/27 编程问答 28 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mybatis-plus的 mapper.xml 路径配置的坑 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

mybatis-plus今天遇到一个问题,就是mybatis 没有读取到mapper.xml 文件。

#实体扫描,多个package用逗号或者分号分隔 mybatis-plus:typeAliasesPackage: com.gblfy.springboot.mybatisplus.entitymapper-locations:- classpath*:com/gblfy/springboot/**/mapping/*.xml


特此记录一下,问题如下:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.husy.mapper.SystemUserMapper.findUserByNameat com.baomidou.mybatisplus.core.override.MybatisMapperMethod$SqlCommand.<init>(MybatisMapperMethod.java:242)at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:54)at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:65)at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:65)at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:60)at com.sun.proxy.$Proxy72.findUserByName(Unknown Source)at com.husy.service.impl.SystemUserServiceImpl.findUserByName(SystemUserServiceImpl.java:23)

解决方案1:

添加如下配置即可

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

解决方案2:
把mapping文件夹和文件移动到resources目录下面

#实体扫描,多个package用逗号或者分号分隔 mybatis-plus:typeAliasesPackage: com.gblfy.springboot.mybatisplus.entitymapper-locations:- classpath*:/mapping/*.xml

总结

以上是生活随笔为你收集整理的mybatis-plus的 mapper.xml 路径配置的坑的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。