Install
openclaw skills install autotable-usageAutoTable 框架完整使用指南。基于 JDBC 的自动建表框架(非 MyBatis 依赖),支持 9 种数据库。覆盖注解配置、多数据库适配、生命周期钩子、SPI 扩展、SQL 审计、数据初始化、多数据源等。当用户询问 AutoTable 的用法、注解、配置、扩展、最佳实践时激活。
openclaw skills install autotable-usageAutoTable 是一个基于 JDBC(commons-dbutils)的自动维护数据库表结构的 Java 框架,不依赖任何 ORM 框架,可与 MyBatis/MyBatis-Plus/MyBatis-Flex/JPA 等共存。
| 用户问题 | 参考文档 |
|---|---|
| 如何安装、启用、定义实体 | references/quick-start.md |
| 某个注解的完整属性、用法 | references/annotation-reference.md |
| Spring Boot / Solon 配置项 | references/configuration.md |
| 生命周期回调、拦截器 | references/lifecycle.md |
| MySQL / Doris / PostgreSQL 专属功能 | references/database-specific.md |
| 类型映射、自定义类型转换 | references/type-mapping.md |
| 多数据源配置 | references/multi-datasource.md |
| 生产部署、测试、最佳实践 | references/best-practices.md |
| 内部架构、SPI 扩展、自定义策略 | references/architecture.md |
| 模式 | 说明 | 适用场景 |
|---|---|---|
update | 增量更新表结构(默认) | 开发环境 |
validate | 仅校验,不一致则报错 | 生产环境 |
create | 删表重建(⚠️ 丢数据) | 测试环境 |
none | 不做任何处理 | 禁用 |
MySQL、MariaDB、PostgreSQL、Oracle、SQLite、H2、Doris、达梦(DM)、人大金仓(KingBase)
@AutoTable (类级) → 声明建表
├── @TableIndex (类级,组合索引,可重复)
├── @MysqlEngine / @MysqlCharset (MySQL 类级)
├── @MysqlTableFullTextIndex (MySQL 全文索引)
├── @DorisTable (Doris 类级)
│
@AutoColumn (字段级) → 聚合配置
├── @ColumnName / @ColumnType / @ColumnNotNull
├── @ColumnDefault / @ColumnComment
├── @PrimaryKey / @AutoIncrement
├── @Index (字段级索引)
├── @Ignore (忽略字段)
├── @MysqlFullTextIndex / @MysqlColumnCharset 等
├── @DorisColumn
└── @AutoColumns (多数据库适配容器)
<!-- Spring Boot(兼容 2.x 和 3.x) -->
<dependency>
<groupId>org.dromara.autotable</groupId>
<artifactId>auto-table-spring-boot-starter</artifactId>
<version>2.5.17</version>
</dependency>
<!-- Solon -->
<dependency>
<groupId>org.dromara.autotable</groupId>
<artifactId>auto-table-solon-plugin</artifactId>
<version>2.5.17</version>
</dependency>
// Spring Boot
@EnableAutoTable
@SpringBootApplication
public class Application { ... }
// Solon
@EnableAutoTable // 标注在 @SolonMain 类上
public class Application { ... }
@Data
@AutoTable(comment = "用户表")
public class User {
@PrimaryKey(autoIncrement = true)
private Long id;
@AutoColumn(comment = "用户名", notNull = true)
private String username;
}
create 模式会删表:测试完务必切回 updateauto-drop-table/column 生产环境必须关闭,会造成数据丢失auto_idx_ 前缀,超长时 hash 处理super-insert-position 默认 after(父类字段在子类后面),不符合直觉时可改为 beforemysql.alter-table-separate-dropdoris.update-limit-table-data-length),需按需调整