当前位置:网站首页>Screw数据库文档生成器
Screw数据库文档生成器
2022-06-22 18:00:00 【阿国GG在学习】
一、引入依赖
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.3</version>
</dependency>二、在测试类编写
package com.bojian.digital.clinic;
import cn.smallbun.screw.core.*;
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 org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.sql.DataSource;
import java.util.ArrayList;
@SpringBootTest
class ClinicApplicationTests {
@Test
void documentGeneration() {
//数据源
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/Datebase");
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("文件路径")
//打开目录
.openOutputDir(true)
//文件类型
.fileType(EngineFileType.HTML)
//生成模板实现
.produceType(EngineTemplateType.freemarker)
//自定义文件名称
// .fileName("SQl.html")
.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();
}
}
运行之后再对应地目录种查看生成的文件
边栏推荐
- 到底使用Thread还是Service?
- Flush difficult to open an account? Is it safe to open an account online?
- 預訓練語言模型,bert,RoFormer-Sim又稱SimBERTv2
- 《被讨厌的勇气》读后感
- Dynamically changing the style of label elements in a loop
- 第八届 GopherChina 大会蓄势待发!
- Detailed explanation of shell script (x) -- how to use sed editor
- Redis中的布隆过滤器与布谷鸟过滤器,你了解多少?
- Some technical ideas:
- After reading the hated courage
猜你喜欢

《被讨厌的勇气》读后感

2022 operation of simulated examination platform for examination question bank of welder (elementary) special operation certificate

Play typical usage scenarios of kubernetes | dashboard for 5 minutes every day

shell脚本详解(十)——sed编辑器的使用方法

如何在 FlowUs和Notion 等笔记软件中进行任务管理?

3GPP 5g R17 standard is frozen, and redcap as an important feature deserves attention!

Several important viewpoints on operation and maintenance, monitoring and aiops

Iplook and SBC establish long-term cooperation

wpa_ CLI parameter description

集群、分布式、微服务概念和区别
随机推荐
数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级
泡泡玛特:空洞的灵魂需要故事
集群、分布式、微服务概念和区别
PostgreSQL 字符串分隔函数(regexp_split_to_table)介绍以及示例应用
贪心之区间问题(1)
Flutter系列-flutter路由管理
有效的括号
Detailed explanation of session mechanism and related applications of session
Pull down refresh and pull up to load more listviews
JSP connection MySQL total error
Flutter系列-搭建Flutter开发环境
Active Directory用户登录报告
Implementing Domain Driven Design - using ABP framework - solution overview
Programmer's tool encyclopedia [continuous update]
同花顺好用么?手机开户安全么?
贪心之区间问题(2)
UE4_ Ue5 make 3dui follow the camera orientation (attached works)
一些技术想法:
输入两个字符串,输出最长相同子串
shell脚本详解(七)——正则表达式、sort、uniq、tr