资料参考:

https://blog.csdn.net/weixin_43797561/article/details/122809269
https://blog.csdn.net/qq_33177268/article/details/124325242

新建Maven工程:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>cn.cloud9</groupId>
<artifactId>MySQL-Document</artifactId>
<version>1.0-SNAPSHOT</version> <dependencies>
<!--文档生成工具 -->
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency> <!--数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.25</version>
</dependency> <!--数据库连接池 -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.5.1</version>
</dependency> <!-- ini 配置读取 -->
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency> <!--————————————————-->
<!--版权声明:本文为CSDN博主「风华正茂_Yang」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。-->
<!--原文链接:https://blog.csdn.net/weixin_43797561/article/details/122809269-->
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Application</mainClass>
<!-- 主类的位置,例如上图文件,主类配置应为: -->
<!-- <mainClass>top.nihilwater.App</mainClass> -->
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> </project>

  

启动类编写:

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 org.ini4j.Profile;
import org.ini4j.Wini; import javax.sql.DataSource;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; /**
* @projectName: MySQLDocument
* @author: Cloud9
* @date: 2022年05月26日 16:23
* @version: 1.0
*/
public class Application { private static Wini configFile; static {
try {
configFile = new Wini(new File("config.ini"));
} catch (Exception e) {
e.printStackTrace();
}
} /**
* 数据源初始化
* @param
* @return javax.sql.DataSource
* @author Cloud9
* @createTime 2022/5/26 17:26
*
*/
private static DataSource initDataSource() {
try {
Profile.Section section = configFile.get("mysql-config");
//数据源
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName(section.get("driverClassname"));
hikariConfig.setJdbcUrl(section.get("jdbcUrl"));
hikariConfig.setUsername(section.get("username"));
hikariConfig.setPassword(section.get("password"));
//设置可以获取tables remarks信息
final String TABLE_REMARK = "useInformationSchema";
hikariConfig.addDataSourceProperty(TABLE_REMARK, section.get(TABLE_REMARK, "true"));
hikariConfig.setMinimumIdle(Integer.parseInt(section.get("min-idle", "2")));
hikariConfig.setMaximumPoolSize(Integer.parseInt(section.get("max-pool-size", "10")));
return new HikariDataSource(hikariConfig);
} catch (Exception e) {
e.printStackTrace();
}
return null;
} /**
* 模板引擎初始化
* @return cn.smallbun.screw.core.engine.EngineConfig
* @author Cloud9
* @createTime 2022/5/26 17:31
*/
private static EngineConfig initEngineConfig() {
Profile.Section section = configFile.get("template-engine-config"); //生成配置
return EngineConfig.builder()
//生成文件路径
.fileOutputDir(section.get("output-dir", ".\\"))
//打开目录
.openOutputDir(true)
//文件类型
.fileType(EngineFileType.HTML)
//生成模板实现
.produceType(EngineTemplateType.freemarker)
//自定义文件名称
.fileName(section.get("file-name", "测试案例"))
.build();
} /**
* 处理配置初始化
* @return cn.smallbun.screw.core.engine.EngineConfig
* @author Cloud9
* @createTime 2022/5/26 17:31
*/
private static ProcessConfig initProcessConfig() {
Profile.Section section = configFile.get("ignore-config");
Profile.Section designateSection = configFile.get("designate-config"); if (null == section && null == designateSection) return ProcessConfig.builder().build(); return ProcessConfig.builder()
//指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置
//根据名称指定表生成
.designatedTableName(getMultiParam(designateSection.get("table")))
//根据表前缀生成
.designatedTablePrefix(getMultiParam(designateSection.get("prefix")))
//根据表后缀生成
.designatedTableSuffix(getMultiParam(designateSection.get("suffix")))
//忽略表名
.ignoreTableName(getMultiParam(section.get("table")))
//忽略表前缀
.ignoreTablePrefix(getMultiParam(section.get("prefix")))
//忽略表后缀
.ignoreTableSuffix(getMultiParam(section.get("suffix")))
.build();
} /**
* 获取一组参数
* @return cn.smallbun.screw.core.engine.EngineConfig
* @author Cloud9
* @createTime 2022/5/26 17:31
*/
private static List<String> getMultiParam(String paramItem) {
return null == paramItem ? new ArrayList<>() :
Arrays.stream(paramItem.split(","))
.map(String::trim)
.collect(Collectors.toList());
} /**
* 全部配置初始化
* @return cn.smallbun.screw.core.engine.EngineConfig
* @author Cloud9
* @createTime 2022/5/26 17:31
*/
private static Configuration initConfiguration() {
final Profile.Section section = configFile.get("doc-config"); return Configuration.builder()
.title(section.get("title", "测试文档"))
.organization(section.get("organization", "cloud9"))
.organizationUrl(section.get("organizationUrl", "https://home.cnblogs.com/u/mindzone/"))
.version(section.get("version", "1.0.0")) //版本
.description(section.get("description", "数据库设计文档生成")) //描述
//数据源
.dataSource( initDataSource())
//生成配置
.engineConfig(initEngineConfig())
//生成配置
.produceConfig( initProcessConfig())
.build();
} public static void main(String[] args) {
//执行生成
new DocumentationExecute(initConfiguration()).execute();
}
}

  

配置文件:

[mysql-config]
driverClassname = com.mysql.cj.jdbc.Driver
jdbcUrl = jdbc:mysql://localhost:3306/ymcd_aisw?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username = root
password = 123456
useInformationSchema = true
max-pool-size = 5 [template-engine-config]
output-dir = .
file-name = xx系统MySQL设计文档 [designate-config] [ignore-config]
table = test_user, test_group
prefix = gen_, qrtz_, sys_
suffix = _test [doc-config]
title = xx系统MySQL设计文档
version = 1.0.0
description = xx系统设计文档生成
organization = Cloud9
organizationUrl = https://home.cnblogs.com/u/mindzone/

配置文件存放位置:

打包项目:

声明启动类:

无主清单,请参考:

https://blog.csdn.net/weixin_49736959/article/details/108969870

文件结构:

 

【Java】Mysql文档生成工具的更多相关文章

  1. 基于Mybatis的Mysql数据库文档生成工具,支持生成docx(原创)

    今天不写android--也写写数据库相关的东西 -------------------- 今日老夫闲来无事,设计了一款数据库文档生成工具 眼下仅仅支持mysql 主要是生成docx的 下载链接:下载 ...

  2. Java 的 Api 文档生成工具 JApiDocs 程序文档工具

    JApiDocs 详细介绍 简介 JApiDocs 是一个符合 Java 编程习惯的 Api 文档生成工具.最大程度地利用 Java 的语法特性,你只管用心设计好接口,添加必要的注释,JApiDocs ...

  3. 【转载】Java Restful API 文档生成工具 smart-doc

    谁说生成api文档就必须要定义注解? 谁说生成接口请求和返回示例必须要在线? 用代码去探路,不断尝试更多文档交付的可能性. 如果代码有生命,为什么不换种方式和它对话! 一.背景 没有背景.就自己做自己 ...

  4. DBImport v3.44 中文版发布:数据库数据互导及文档生成工具(IT人员必备)

    前言: 距离上一个版本V3.3版本的文章发布,已经是1年10个月前的事了. 其实版本一直在更新,但也没什么大的功能更新,总体比较稳定,所以也不怎么写文介绍了. 至于工作上的事,之前有半年时间跑去学英语 ...

  5. 文档生成工具doxygen+图像生成工具GraphViz

    文档生成工具doxygen+图像生成工具GraphViz 虽然jdk自带的javadoc也很好用,不过使用doxygen+GraphViz 的组合可以生成许多强大的图(类图.协作图.文件包含/被包含图 ...

  6. 使用Objective-C的文档生成工具:appledoc

    使用Objective-C的文档生成工具:appledoc 前言 做项目的人多了,就需要文档了.今天开始尝试写一些项目文档.但是就源代码来说,文档最好和源码在一起,这样更新起来更加方便和顺手.象 Ja ...

  7. 使用Objective-C的文档生成工具

    前言 做项目的人多了,就需要文档了.今天开始尝试写一些项目文档.但是就源代码来说,文档最好和源码在一起,这样更新起来更加方便和顺手.象Java语言本身就自带javadoc命令,可以从源码中抽取文档.今 ...

  8. Markdown 文档生成工具

    之前用了很多Markdown 文档生成工具,发现有几个挺好用的,现在整理出来,方便大家快速学习. loppo: 非常简单的静态站点生成器 idoc:简单的文档生成工具 gitbook:大名鼎鼎的文档协 ...

  9. Doxygen自动文档生成工具在Eclipse中的集成及使用举例

    你有为软件编写说明文档的苦恼吗?当别人甩给你一个庞大的系统,让你根据里面的代码注释理解后写出一份完整的开发文档,你会怎么办?一个个的看代码 然后耗时N天来写吗?这既是一份苦差事也极其耗时,有没有更好的 ...

  10. DBCHM -最简单、最实用的数据库文档生成工具

    项目介绍 DBCHM 是一款数据库文档生成工具! 该工具从最初支持chm文档格式开始,通过开源,集思广益,不断改进,又陆续支持word.excel.pdf.html.xml.markdown等文档格式 ...

随机推荐

  1. 小程序视图组件 scroll-view

    视图容器组件 3.2.1.swiper 滑块视图容器. https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html 3 ...

  2. 程序员面试金典-面试题 01.03. URL化

    题目: URL化.编写一种方法,将字符串中的空格全部替换为%20.假定该字符串尾部有足够的空间存放新增字符,并且知道字符串的"真实"长度.(注:用Java实现的话,请使用字符数组实 ...

  3. ETL工具-nifi干货系列 第十讲 处理器RouteOnAttribute(数据流路由)

    1.今天我们一起来学习下处理器RouteOnAttribute,此处理器的作用是根据属性值进行路由进而来控制数据流的走向.类似于java中的if-else或者switch-case.如下图所示. Ge ...

  4. C#.NET 4.8 WEBP 转 GIF

    C#.NET 4.8 WEBP 转 GIF 项目是.NET 4.8. nuget 引用 Magick.NET-Q16-AnyCPU ,版本:7.14.5.高版本,如:12.2 已经不支持.NET FR ...

  5. Promise 期约

    Promise 期约之前 回调地狱 设想这样一个经常发生的场景,我们希望处理Ajax请求的结果,所以我们将处理请求结果的方法作为回调传入,需要将请求结果继续处理,这就导致我们陷入了回调地狱 doSom ...

  6. Hibernate Validator 校验注解

    Hibernate Validator 校验注解/** * 认识一些校验注解Hibernate Validator * * @NotNull 值不能为空 * @Null 值必须为空 * @Patter ...

  7. Azure Storage Blob 启用sftp协议支持

    背景 我这边需要给前端同学一个上传静态文件的地方,比如js.css.图片.icons等等,前端上传后直接在项目中:我这边用的是Azure Storage blob:为了单独分配权限,我这边打算启用SF ...

  8. mysql这个垃圾迁移数据费劲半天

    mysql垃圾得很!  对于一些小系统还可以.大型系统自己找麻烦--必须有高昂的人工费! 没有高昂的人工(必须有好的程序员和工程师才能解决一些复杂的问题),构建基于大量数据的应用,非常麻烦. 而这些费 ...

  9. 大模型重塑软件开发,华为云AI原生应用架构设计与实践分享

    在ArchSummit全球架构师峰会2024上,华为云aPaaS平台首席架构师马会彬受邀出席,和技术爱好者分享AI原生应用引擎的架构与实践. AI大模型与AI重塑软件的大趋势下,软件会发生哪些本质的变 ...

  10. CSS和CSS3(背景,图片,浮动等)

    CSS和CSS3背景图片 CSS的背景,无法伸缩图片. <!DOCTYPE html> <html lang="en"> <head> < ...