{"id":22446178,"url":"https://github.com/muxiangqiu/spring-boot-multidatasource","last_synced_at":"2025-08-01T20:31:44.376Z","repository":{"id":144611712,"uuid":"111817890","full_name":"muxiangqiu/spring-boot-multidatasource","owner":"muxiangqiu","description":"spring-boot的多数据源功能的扩展实现","archived":false,"fork":false,"pushed_at":"2018-01-11T06:18:26.000Z","size":18,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T07:21:14.655Z","etag":null,"topics":["datasource","multidatasource","spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muxiangqiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-23T14:18:00.000Z","updated_at":"2020-09-17T07:46:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"12dabd70-7e4f-4b77-b61f-74db71574af4","html_url":"https://github.com/muxiangqiu/spring-boot-multidatasource","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/muxiangqiu/spring-boot-multidatasource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muxiangqiu%2Fspring-boot-multidatasource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muxiangqiu%2Fspring-boot-multidatasource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muxiangqiu%2Fspring-boot-multidatasource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muxiangqiu%2Fspring-boot-multidatasource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muxiangqiu","download_url":"https://codeload.github.com/muxiangqiu/spring-boot-multidatasource/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muxiangqiu%2Fspring-boot-multidatasource/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268291389,"owners_count":24226852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datasource","multidatasource","spring-boot"],"created_at":"2024-12-06T03:26:31.250Z","updated_at":"2025-08-01T20:31:44.331Z","avatar_url":"https://github.com/muxiangqiu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 简介\n在单数据源项目中，spring-boot提供属性文件配置的方式，配置我们的数据源，如下：\n```java\n#数据源配置\nspring.dataSource......\n```\n如果项目需要多个数据源的话，spring-boot就没有更好的方式了，只能通过自己构造DataSource的spring bean了。\n## 多数据源配置\n1. 单数据源情况和spring boot提供的方式是一样的。无须额外的学习\n2. 多数据源和单数据源配置方式差不多，代码如下：\n```java\nspring.dataSource.........\nspring.dataSource1........\nspring.dataSource2........\n....\nspring.dataSource6........\n```\n代码上可以看出，配置方式和单数据源方式几乎一样，需要特别主要的是：这种通过属性配置来定义多数据源的数据源的个数是有限制的，最多7个数据源。这对绝大多数应用场景是远远足够了的。万一不够，我们还可以spring原生的方式：构建自己的DataSource对象放入spring容器中，效果也是一样的。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuxiangqiu%2Fspring-boot-multidatasource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuxiangqiu%2Fspring-boot-multidatasource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuxiangqiu%2Fspring-boot-multidatasource/lists"}