mybatis-plus今天遇到一个问题,就是mybatis 没有读取到mapper.xml 文件。
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.husy.mapper.SystemUserMapper.findUserByName at com.baomidou.mybatisplus.core.override.MybatisMapperMethod S q l C o m m a n d . < i n i t > ( M y b a t i s M a p p e r M e t h o d . j a v a : 242 ) a t c o m . b a o m i d o u . m y b a t i s p l u s . c o r e . o v e r r i d e . M y b a t i s M a p p e r M e t h o d . < i n i t > ( M y b a t i s M a p p e r M e t h o d . j a v a : 54 ) a t a p p e r P r o x y . l a m b d a SqlCommand.<init>(MybatisMapperMethod.java:242) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:54) at apperProxy.lambda SqlCommand.<init>(MybatisMapperMethod.java:242)atcom.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:54)atapperProxy.lambdacachedMapperMethod 0 ( M y b a t i s M a p p e r P r o x y . l a m b d a 0(MybatisMapperProxy.lambda 0(MybatisMapperProxy.lambdacachedMapperMethod$0(MybatisMapperProxy.java:65)
at
解决: 只需将配置文件 改成这样即可
mybatis-plus:
#mapper-locations: classpath:mapper/.xml
mapper-locations: classpath:com/byd/qte/task/mapper/xml/.xml
我们将 xml文件放到了 java目录下,并没有放到 resource目录下。
配置文件如上配置,
Pom文件如下
src/main/java
/*.properties
/*.xml
false
src/main/resources
true
依赖文件
com.baomidou mybatis-plus-boot-starter 3.5.3.1