作用:将mapper.xml 文件配置到mybatis-config.xml的环境中。
<mapper url=”file…xml”这种是在硬盘中读取的,这种几乎不用
mappers----映射器(也就是mybatis--config.xml内引用mapper.xml文件)
使用mapper接口路径
这里所谓的mapper接口路径。实际上就是dao的接口路径。在mybatis中,通常把dao的包叫做mapper!!类名,也叫做mapper

  1. 定义一个接口
  2. 在接口所在的包中定义mapper.xml(也就是将xml文件存放在和mapper接口一个包下)
  3. 在mybatis-config.xml 中通过class路径,引入mapper。要求mapper.xml 中的名称空间是类的接口的全路径

例如:
mappers----映射器(也就是mybatis--config.xml内引用mapper.xml文件)

使用mapper接口扫描包(一次将所有的xml文件导入)

mappers----映射器(也就是mybatis--config.xml内引用mapper.xml文件)
这个扫描的包为:
mappers----映射器(也就是mybatis--config.xml内引用mapper.xml文件)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-25
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-12-26
  • 2021-06-13
  • 2021-12-07
相关资源
相似解决方案