springboot項目有時會涉及多數據源,因為我們通常每個數據源創建不同的包路徑,mapper.xml的路徑也不一樣,這個時候就需要引入多個路徑。
數據源1,mapper接口路徑在 mapper包下面,mapper.xml 路徑在 resources/mappers/下面; 數據源2,mapper接口路徑在 mapper/other包下面,mapper.xml 路徑在 resources/mappers/other下面:
配置總共分兩步:
第一步 :
在mybatisplus配置類里面修改掃描包路徑:
第二步:
修項目的application.yml配置文件中配置mapper.xml路徑如下:
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml,classpath*:mapper/other/*.xml