Skip to content

数据库适配

AutoTable 通过 策略模式 + SPI 机制 支持多种数据库,每种数据库都有独立的策略实现。

支持的数据库

数据库策略模块测试版本状态维护者
MySQLauto-table-strategy-mysql5.7+✅ 稳定
MariaDBauto-table-strategy-mysql对应 MySQL✅ 稳定
PostgreSQLauto-table-strategy-pgsql15.5✅ 稳定
Oracleauto-table-strategy-oracle11g / 23ai✅ 稳定@lizhian
达梦auto-table-strategy-dmdm8✅ 稳定@minfc
人大金仓auto-table-strategy-kingbaseV009R001C002B0014✅ 稳定@minfc
H2auto-table-strategy-h22.2.220✅ 稳定
SQLiteauto-table-strategy-sqlite3.35.5✅ 稳定
Dorisauto-table-strategy-doris2.0✅ 稳定@lizhian

按需引入

默认情况下,auto-table-spring-boot-starter 不包含具体数据库策略,需要按需引入:

xml
<!-- 引入所有策略 -->
<dependency>
    <groupId>org.dromara.autotable</groupId>
    <artifactId>auto-table-strategy-all</artifactId>
    <version>2.5.10</version>
</dependency>

<!-- 或单独引入 -->
<dependency>
    <groupId>org.dromara.autotable</groupId>
    <artifactId>auto-table-strategy-mysql</artifactId>
    <version>2.5.10</version>
</dependency>

自动识别

AutoTable 会根据 JDBC 连接自动识别数据库类型,无需手动配置。

也可以在实体上显式指定:

java
@AutoTable(dialect = "MySQL")  // 强制使用 MySQL 策略
public class User {
    // ...
}

扩展新数据库

如需支持新的数据库,可以实现 IStrategy 接口并通过 SPI 注册。

详见 自定义策略

Released under the Apache 2.0 License.