3 Star 37 Fork 7

change / spring-data-jdbc-mybatis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
multi-datasource.md 982 Bytes
一键复制 编辑 原始数据 按行查看 历史
change 提交于 2024-02-01 08:42 . [new]update version and readme
@Configuration
public class DbConfig {
    @Bean(name = "dataSource")
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource mainDataSource() {
        return DataSourceBuilder.create().build();
    }
    
    @Bean(name = "orderDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.order")
    public DataSource oldDataSource() {
        return DataSourceBuilder.create().build();
    }
    
    @Bean("dataSourceWrapper")
    public DataSourceWrapper dataSourceWrapper(@Qualifier("dataSource")DataSource dataSource) {
        return new DataSourceWrapper(dataSource,"dataSource");
    }
 

    @Bean("orderDataSourceWrapper")
    public DataSourceWrapper oldDataSourceWrapper(@Qualifier("orderDataSource")DataSource dataSource) {
        return new DataSourceWrapper(dataSource,"orderDataSource");
    }

}
@DataSourceKey("orderDataSource")
public interface OrderQueryDao extends QueryRepository {
}
Java
1
https://gitee.com/vonchange/spring-data-jdbc-mybatis.git
git@gitee.com:vonchange/spring-data-jdbc-mybatis.git
vonchange
spring-data-jdbc-mybatis
spring-data-jdbc-mybatis
master

搜索帮助