springboot+mybatisplus配置多个mapper路径

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

猜你喜欢

转载自www.cnblogs.com/zscwb/p/12501870.html