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


spring boot整合mybatis-plus使用mysql和Oracle多数据源的时候,遇到如下问题:

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$SqlCommand.(MybatisMapperMethod.java:242)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.(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)

首先我放xml的包的是没问题的,而是引入的架包和配置问题,问题配置如下:

mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.msl.moniter.entity

解决方法:请将mybatis-plus改成mybatis,mybatis,mybtis,重要的说三遍,

https://blog.csdn.net/u013234928/article/details/94060733

https://blog.csdn.net/qq_21747795/article/details/81217264