1. 程式人生 > >springboot|mybatis掃描任意路徑下的mapper檔案

springboot|mybatis掃描任意路徑下的mapper檔案

springboot與mybatis整合時會發現mapper檔案必須放在resource下,這樣對於一些人很不習慣。這樣我們說一下解決辦法。
**

application.yml的配置

**

mybatis:
  config-location:classpath:mybatis/mybatis.cfg.xml        # mybatis配置檔案所在路徑
  mapper-locations:classpath*:com/example/demo/**/dao/xml/*.xml                       # mapper對映檔案

**
一定要注意classpath*

application.properties的配置

**

#mybatis的mapper配置檔案
# mybatis配置檔案所在路徑
mybatis.config-location:classpath:mybatis-config.xml
# 所有的mapper對映檔案
mybatis.mapper-locations:classpath*:com/springboot/mapper/*.xml