程序员必备推荐一款与Swagger媲美的数据库文档生成工具

本文涉及的产品
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: 程序员必备推荐一款与Swagger媲美的数据库文档生成工具

# 简介

 

在企业级开发中、我们经常会有编写数据库表结构文档的时间付出,繁琐麻烦且容易出错,不过有了screw,你只需要在项目中进行集成,配置即可,轻松生成数据库表结构文档。

 

# 特点

 

  • 简洁、轻量、设计良好
  • 多数据库支持
  • 多种格式文档
  • 灵活扩展
  • 支持自定义模板

 

# 数据库支持

 

  • MySQL
  • MariaDB
  • TIDB
  • Oracle
  • SqlServer
  • PostgreSQL
  • Cache DB

 

# 文档生成支持

 

  • html
  • word
  • markdwon

 

# 文档截图

 

# 手动运行screw

 

引入依赖

 

<dependency>    <groupId>cn.smallbun.screw</groupId>    <artifactId>screw-core</artifactId>    <version>${lastVersion}</version> </dependency>

 

编写代码

 

/** * 文档生成 */void documentGeneration() {   //数据源   HikariConfig hikariConfig = new HikariConfig();   hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");   hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/database");   hikariConfig.setUsername("root");   hikariConfig.setPassword("password");   //设置可以获取tables remarks信息   hikariConfig.addDataSourceProperty("useInformationSchema", "true");   hikariConfig.setMinimumIdle(2);   hikariConfig.setMaximumPoolSize(5);   DataSource dataSource = new HikariDataSource(hikariConfig);   //生成配置   EngineConfig engineConfig = EngineConfig.builder()         //生成文件路径         .fileOutputDir(fileOutputDir)         //打开目录         .openOutputDir(true)         //文件类型         .fileType(EngineFileType.HTML)         //生成模板实现         .produceType(EngineTemplateType.freemarker)         //自定义文件名称         .fileName("自定义文件名称").build();

 

 //忽略表   ArrayList<String> ignoreTableName = new ArrayList<>();   ignoreTableName.add("test_user");   ignoreTableName.add("test_group");   //忽略表前缀   ArrayList<String> ignorePrefix = new ArrayList<>();   ignorePrefix.add("test_");   //忽略表后缀       ArrayList<String> ignoreSuffix = new ArrayList<>();   ignoreSuffix.add("_test");   ProcessConfig processConfig = ProcessConfig.builder()         //指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置       //根据名称指定表生成     .designatedTableName(new ArrayList<>())     //根据表前缀生成     .designatedTablePrefix(new ArrayList<>())     //根据表后缀生成       .designatedTableSuffix(new ArrayList<>())         //忽略表名         .ignoreTableName(ignoreTableName)         //忽略表前缀         .ignoreTablePrefix(ignorePrefix)         //忽略表后缀         .ignoreTableSuffix(ignoreSuffix).build();   //配置   Configuration config = Configuration.builder()         //版本         .version("1.0.0")         //描述         .description("数据库设计文档生成")         //数据源         .dataSource(dataSource)         //生成配置         .engineConfig(engineConfig)         //生成配置         .produceConfig(processConfig)         .build();   //执行生成   new DocumentationExecute(config).execute();}

 

# Maven插件运行screw

 

<build>    <plugins>        <plugin>            <groupId>cn.smallbun.screw</groupId>            <artifactId>screw-maven-plugin</artifactId>            <version>${lastVersion}</version>            <dependencies>                <dependency>                    <groupId>com.zaxxer</groupId>                    <artifactId>HikariCP</artifactId>                    <version>3.4.5</version>                </dependency>                <dependency>                    <groupId>mysql</groupId>                    <artifactId>mysql-connector-java</artifactId>                    <version>8.0.20</version>                </dependency>            </dependencies>            <configuration>                <username>root</username>                <password>password</password>                <driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>                <jdbcUrl>jdbc:mysql://127.0.0.1:3306/xxxx</jdbcUrl>                <fileType>HTML</fileType>                <openOutputDir>false</openOutputDir>                <produceType>freemarker</produceType>                <fileName>测试文档名称</fileName>                <description>数据库文档生成</description>                <version>${project.version}</version>                <title>数据库文档</title>            </configuration>            <executions>                <execution>                    <phase>compile</phase>                    <goals>                        <goal>run</goal>                    </goals>                </execution>            </executions>        </plugin>    </plugins></build>
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
6天前
|
运维 Oracle 关系型数据库
screw生成数据库文档
screw生成数据库文档
22 12
|
13天前
|
SQL 关系型数据库 MySQL
MySQL数据库-概括与常用图形管理工具
MySQL数据库-概括与常用图形管理工具
|
8天前
|
Java 数据库连接 API
后端开发之用Mybatis简化JDBC的开发快速入门2024及数据库连接池技术和lombok工具详解
后端开发之用Mybatis简化JDBC的开发快速入门2024及数据库连接池技术和lombok工具详解
14 3
|
10天前
|
JavaScript Java 测试技术
基于SpringBoot+Vue的数据库课程在线教学的详细设计和实现(源码+lw+部署文档+讲解等)
基于SpringBoot+Vue的数据库课程在线教学的详细设计和实现(源码+lw+部署文档+讲解等)
23 2
|
20天前
|
SQL 关系型数据库 MySQL
mysqldiff - Golang 针对 MySQL 数据库表结构的差异 SQL 工具
Golang 针对 MySQL 数据库表结构的差异 SQL 工具。https://github.com/camry/mysqldiff
53 7
|
19天前
|
存储 JSON NoSQL
【文档数据库】ES和MongoDB的对比
【文档数据库】ES和MongoDB的对比
145 1
|
2天前
|
Oracle 关系型数据库 Java
Oracle数据库导入工具IMP详解与用法
Oracle数据库导入工具IMP详解与用法
|
3天前
|
数据可视化 Java API
Spring Boot中使用Swagger生成API文档
Spring Boot中使用Swagger生成API文档
|
3天前
|
Java API Spring
Spring Boot中配置Swagger用于API文档
Spring Boot中配置Swagger用于API文档
|
4天前
|
Java API Spring
Spring Boot中配置Swagger用于API文档
Spring Boot中配置Swagger用于API文档