baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.67k stars 1.19k forks source link

多数据源动态切换,mapper.xml配置问题 #215

Closed superlyao closed 4 years ago

superlyao commented 4 years ago

Enviroment

JDK Version(required): 1.8.0_201

SpringBoot Version(required): 2.1.2.RELEASE

dynamic-datasource-spring-boot-starter Version(required): 3.1.0

druid Version(optional):1.1.9

Describe

项目中有多种数据源,

    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setDataSource(dataSource);
    bean.setMapperLocations(resolver.getResources(mapperLocations));
    return bean.getObject();

之前的代码在配置datasource就可以配置setMapperLocations,现在使用动态数据源,如何配置每个数据源的mapperLocations

Expected Result:

Actual Result:

Steps to reproduce

huayanYu commented 4 years ago

https://blog.csdn.net/qq_42685050/article/details/81427865 你可能比较适合静态多数据源。