mapper-locations

顾名思义是一个定义mapper位置的属性

在yml或properties下配置,作用是实现mapper接口配置见mapper和接口的绑定。

Mybatis mapper-locations作用_配置文件

使用场景:

当mapper接口和mapper接口对应的配置文件在

  • 命名上相同
  • 所在的路径相同

Mybatis mapper-locations作用_使用场景_02


则mapper-locations可以不用配置,配置也不会生效。

但是,如果

当mapper接口和mapper接口对应的配置文件在

  • 命名上不同或
  • 所在的路径不同

之一不同,需要配置mapper-locations才能实现接口的绑定

Mybatis mapper-locations作用_开发语言_03


实现接口绑定需要在配置文件中配置:

mybatis.mapper-locations=classpath:mapper/*Mapper.xml