mybatis配置问题记录

org.apache.ibatis.binding.BindingException: Type interface com.xx.dao.UserDao(自己项目的文件) is not known to the MapperRegistry.

原因:MapperRegistry顾名思义 mapper没有注册 好比之前servlet学习的时候 每写一个servlet都要注册 此处也是一样 需要到你自己的mybatis核心配置文件中注册

解决办法

<mappers>
<mapper resource="xxx/xx/xx/xx.xml"/>
</mappers>

Cause: java.io.IOException: Could not find resource com/xx/dao/UserDao.xml(自己项目的xml文件)

原因:xx文件没有找到 但是一看项目中是有文件的 且路径也是对的 当文件存在什么都ok的情况下 一般就是配置问题了

maven约定大于配置 一般的文件都是放到resources文件夹下 现在放到java目录下了 可能存在导不出来等问题 解决办法

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

注意点

在Mybatis核心配置文件中注册Mappers时 如果使用<mappers><package name="xx.xxx.xxx"/></mappers>或者<mappers><mapper class="xxx.xxx.xx.xxx"/></mappers>这两种方式

dao接口和xml文件的名称必须一样必须放在同一个包中

最新文章

  1. Win10升级后回退后无法检测新版本的修复办法
  2. RabbitMQ高可用方案总结
  3. bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  4. CSS中的::after ::before
  5. Vue基础理论
  6. NTP客户端的设置
  7. Asp.Net MVC过滤器小试牛刀
  8. JS的词法作用域
  9. 推荐一款非常好用的java反编译工具(转)
  10. java 制作QQ登录界面
  11. 原理Lambda表达式
  12. 简单开发Apple Watch的步骤
  13. SpringBoot图片上传(三)——调用文件上传项目的方法(同时启动两个项目)
  14. feign调用超时
  15. Beyond Compare 4 提示错误“这个授权密钥已被吊销”的解决办法
  16. [转]python3之日期和时间
  17. Android勒索软件研究报告
  18. ubuntu14.04 提示 卷 文件系统根目录 仅剩余xxx的硬盘空间
  19. 对象拷贝:jQuery extend
  20. Shell脚本 Hello World

热门文章

  1. k8s笔记0528-基于KUBERNETES构建企业容器云手动部署集群记录-4
  2. C#多线程开发-线程基础 01
  3. 剑指 Offer 36. 二叉搜索树与双向链表
  4. grpc基础
  5. vue 点击复制当前网址
  6. 基于Appium,封装自己的常用方法
  7. 2021秋 noip 模拟赛
  8. Linux内核中的Workqueue机制分析
  9. 深入理解SpringBoot核心机制《spring-boot-starter》
  10. 解决FTPClient下载网络文件线程挂起问题