screw数据库表结构文档生成工具

编程入门 行业动态 更新时间:2024-10-11 03:25:13

screw数据库表<a href=https://www.elefans.com/category/jswz/34/1771419.html style=结构文档生成工具"/>

screw数据库表结构文档生成工具

一、简介

        screw(螺丝钉)是一款简洁好用的数据库表结构文档生成工具。日常的开发工作中,经常会和数据库打交道,在某些场景可能会需要数据库表结构的文档,  screw(螺丝钉)是一款简洁好用的数据库表结构文档生成工具。支持多数据库、自定义模板、多种格式文档输出,具备简洁、轻量、设计良好、灵活扩展的特点。目前支持MySQL、Oracle、SqlServer、MariaDB、PostgreSQL等数据库,生成文档目前支持html、word、markdown文档格式。

二、效果图展示

三、使用方式

引入依赖jar:

<!--screw数据库表结构文档生成工具-->    <dependency>      <groupId>cn.smallbun.screw</groupId>      <artifactId>screw-core</artifactId>      <version>1.0.3</version>    </dependency>

核心代码: 

package com.wondersmon.utils;import cn.smallbun.screw.core.Configuration;
import cn.smallbun.screw.core.engine.EngineConfig;
import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType;
import cn.smallbun.screw.core.execute.DocumentationExecute;
import cn.smallbun.screw.core.process.ProcessConfig;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.extern.slf4j.Slf4j;import javax.sql.DataSource;
import java.util.ArrayList;/*** @Description: TODO:screw数据库表结构文档生成工具* @Author: yyalin* 参考网站:* @CreateDate: 2022/4/27 14:51* @Version: V1.0*/
@Slf4j
public class ScrewUtils {public static void runScrew() {//MYSQL数据源HikariConfig hikariConfig = new HikariConfig();hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
//        //hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3308/test?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&autoReconnect=true");
//        //TIDB连接//hikariConfig.setJdbcUrl("jdbc:mysql://10.1.50.190:4000/CDR?useUnicode=true&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull");hikariConfig.setJdbcUrl("jdbc:mysql://10.1.51.215:3306/KTHDC_MDM?useUnicode=true&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull");hikariConfig.setUsername("root");hikariConfig.setPassword("123456");//ORACLE数据源
//        HikariConfig hikariConfig = new HikariConfig();
//        hikariConfig.setDriverClassName("oracle.jdbc.driver.OracleDriver");
//        hikariConfig.setJdbcUrl("jdbc:oracle:thin:@10.1.51.175:1521/jcpt");
//        hikariConfig.setUsername("CDR");
//        hikariConfig.setPassword("CDR");//设置可以获取tables remarks信息 表中文注释hikariConfig.addDataSourceProperty("useInformationSchema", "true");hikariConfig.setMinimumIdle(2);hikariConfig.setMaximumPoolSize(5);DataSource dataSource = new HikariDataSource(hikariConfig);//生成配置EngineConfig engineConfig = EngineConfig.builder()//生成文件路径.fileOutputDir("D:\\\\docFile")//打开目录.openOutputDir(true)//文件类型.fileType(EngineFileType.WORD)   //word或html MD//生成模板实现.produceType(EngineTemplateType.freemarker)//自定义文件名称.build();//配置Configuration config = Configuration.builder()//版本.version("V1.0")//描述.description("数据库设计文档")//数据源.dataSource(dataSource)//生成配置.engineConfig(engineConfig)//生成配置.produceConfig(getProcessConfig()).build();//执行生成new DocumentationExecute(config).execute();}/*** 功能描述:配置生成对应表的筛选条件* @MethodName: getProcessConfig* @MethodParam: []* @Return: cn.smallbun.screw.core.process.ProcessConfig* @Author: yyalin* @CreateDate: 2022/4/27 15:15*/public static ProcessConfig getProcessConfig() {//忽略表ArrayList<String> ignoreTableName = new ArrayList<>();
//        ignoreTableName.add("message");//忽略表前缀ArrayList<String> ignorePrefix = new ArrayList<>();
//        ignorePrefix.add("act_");
//        ignorePrefix.add("flw_");//忽略表后缀ArrayList<String> ignoreSuffix = new ArrayList<>();
//        ignoreSuffix.add("_dictionary");ArrayList<String> designatedTableList = new ArrayList<>();
//        designatedTableList.add("PDCA_DISINFECTION_SUPPLY");
//        designatedTableList.add("PDCA_SURGICAL_INSTRUMENTS");
//        designatedTableList.add("PUB_DIAG_CATA_MAP");ProcessConfig processConfig = ProcessConfig.builder()//指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置//根据名称指定表生成
//                .designatedTableName(new ArrayList<>()).designatedTableName(designatedTableList)//根据表前缀生成.designatedTablePrefix(new ArrayList<>())//根据表后缀生成.designatedTableSuffix(new ArrayList<>())//忽略表名.ignoreTableName(ignoreTableName)//忽略表前缀.ignoreTablePrefix(ignorePrefix)//忽略表后缀.ignoreTableSuffix(ignoreSuffix).build();return processConfig;}//临时使用public static void main(String[] args) {runScrew();}}

注意:可以通过设置忽略表名称、忽略表前缀、忽略表后缀等方式过滤不需要带出的相关表,从而达到指定导出的效果。

同样,可以与springboot更好地集成,只需将上述的参数配置在yml中即可,通过@Value("${spring.datasource.driver-class-name}")的方式获取即可。

更多优秀文章,请扫码关注个人微信公众号或搜索“程序猿小杨”添加。

更多推荐

screw数据库表结构文档生成工具

本文发布于:2024-02-06 17:41:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1751029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结构   文档   数据库   工具   screw

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!