# baomidou/dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务

Repository: https://github.com/baomidou/dynamic-datasource
Canonical: https://ross.abutalabs.com/products/dynamic-datasource
Homepage: https://doc.xiuceyun.cn
Language: Java
License: Apache-2.0
License Family: permissive
Topics: dynamicdatasource, springboot, multidatasource, distributed-transaction, datasource, spring-boot, mybatis, multi-datasource, dynamic-datasource
Last push: 2026-04-28T03:02:17+00:00

## Health v2 (maintenance only)
Score: 67/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 79, release rhythm 34, longevity 100
- inputs: {"age_days": 3050, "days_push": 127, "days_rel": 225, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 5184, forks 1240 (observed 2026-08-28T04:09:11.845542+00:00)

## What it is
A Spring Boot starter that enables rapid integration of multiple, dynamically switchable data sources in Java applications. It supports datasource grouping, read/write splitting, master-slave setups, lazy loading, encrypted credentials, and Seata-based distributed transactions.

## Use cases
- connect to multiple databases in a spring boot app
- implement read-write splitting with master and slave databases
- switch datasources dynamically at runtime with annotations
- manage distributed transactions across multiple datasources with seata
- load balance queries across a group of replica databases
- encrypt database credentials in spring boot configuration
- add or remove datasources without restarting the application

## When to choose
- you use Spring Boot with Mybatis or Mybatis-Plus and need multiple databases
- you want annotation-based datasource switching with read/write splitting
- you need Seata-based distributed transactions across datasources
- you want lazy datasource creation or runtime datasource management

## When to avoid
- you are not on the JVM/Spring Boot stack
- you need full SQL sharding rather than simple datasource switching - consider ShardingSphere
- you need a framework-agnostic solution outside Spring's ecosystem

## Facets
- artifact type: library
- maturity: active
- function: database, database-driver, middleware, configuration-management
- domain: databases, backend, web-development, developer-tools
- platform: jvm
- tags: spring-boot-starter, mybatis, read-write-splitting, multi-datasource, seata, distributed-transaction, master-slave, spring-boot

## Member repositories
- baomidou/dynamic-datasource (main) score 67

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:11.845542+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:01:47.037141+00:00, confidence not recorded.
  - readme: https://github.com/baomidou/dynamic-datasource (fetched 2026-08-28T04:09:11.845542+00:00, sha 33963a235dd0)
  - homepage: https://doc.xiuceyun.cn (fetched 2026-08-29T08:55:38.847590+00:00, sha 5fc43ddc39e7)
- Data as of 2026-08-30T08:39:29.467469+00:00.
