当前位置:网站首页>jav一键生成数据库文档
jav一键生成数据库文档
2022-08-03 23:10:00 【JamonWang】
1、使用方式为:
screw(螺丝钉)
2、下图为例子:

3、数据库支持
MySQL、MariaDB、TIDB、Oracle、SqlServer、Cache DB、PostgreSQL
4、生成方式一:插件方式 - pom中添加插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-maven-plugin</artifactId>
<version>1.0.3</version>
<dependencies>
<!-- HikariCP -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.5</version>
</dependency>
<!--mysql driver-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
</dependencies>
<configuration>
<!--username-->
<username>root</username>
<!--password-->
<password>root</password>
<!--driver-->
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<!--jdbc url-->
<jdbcUrl>jdbc:mysql://127.0.0.1:3306/jamoncloud?serverTimezone=Asia/Shanghai</jdbcUrl>
<!--生成文件类型-->
<!-- <fileType>HTML</fileType>-->
<!-- <fileType>WORD</fileType>-->
<fileType>MD</fileType>
<!--打开文件输出目录-->
<openOutputDir>false</openOutputDir>
<!--生成模板-->
<produceType>freemarker</produceType>
<!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
<!--<docName>测试文档名称</docName>-->
<!--描述-->
<description>数据库文档生成</description>
<!--版本-->
<version>${project.version}</version>
<!--标题-->
<title>fire数据库文档</title>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>点击screw:run 会生成文档在目录中的doc目录中, 生成的文档支持三种 HTML、WORD、MD

5、生成方式二:
添加pom
<!-- screw核心 螺丝钉 生成数据库文档-->
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency>测试类中添加如下方法,执行此方法即可
@SpringBootTest
public class documentGeneration {
@Autowired
ApplicationContext applicationContext;
@Test
public void contextLoads() {
//数据源:HikariCP 线程池, SpringBoot 2.0开始内置了HikariCP,2.0之前的版本需要引入依赖
HikariConfig hikariConfig = new HikariConfig();
// com.mysql.jdbc.Driver MySQL5驱动;com.mysql.cj.jdbc.Driver MySQL6之后的驱动
hikariConfig.setDriverClassName("com.mysql.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/jamoncloud?serverTimezone=Asia/Shanghai");
hikariConfig.setUsername("root");
hikariConfig.setPassword("root");
//设置可以获取tables remarks信息
hikariConfig.addDataSourceProperty("useInformationSchema", "true");
hikariConfig.setMinimumIdle(2);
hikariConfig.setMaximumPoolSize(5);
DataSource dataSourceMysql = new HikariDataSource(hikariConfig);
// DataSource dataSourceMysql = applicationContext.getBean(DataSource.class);
// 生成文件配置
String path = System.getProperty ("user.dir") + "\\doc";
EngineConfig engineConfig = EngineConfig.builder()
// 生成文件路径,自己mac本地的地址,这里需要自己更换下路径
.fileOutputDir(path)
// 打开目录
.openOutputDir(false)
// 文件类型
.fileType(EngineFileType.MD)
// 生成模板实现
.produceType(EngineTemplateType.freemarker).build();
// 生成文档配置(包含以下自定义版本号、描述等配置连接)
Configuration config = Configuration.builder()
.version("1.0.3")
.description("生成文档信息描述")
.dataSource(dataSourceMysql)
.engineConfig(engineConfig)
.produceConfig(getProcessConfig())
.build();
// 执行生成
new DocumentationExecute(config).execute();
}
/**
* 配置想要生成的表+ 配置想要忽略的表
*
* @return 生成表配置
*/
public static ProcessConfig getProcessConfig() {
// 忽略表名
List<String> ignoreTableName = Arrays.asList("a", "test_group");
// 忽略表前缀,如忽略a开头的数据库表
List<String> ignorePrefix = Arrays.asList("a", "t");
// 忽略表后缀
List<String> ignoreSuffix = Arrays.asList("_test", "czb_");
return ProcessConfig.builder()
//根据名称指定表生成
// .designatedTableName(Arrays.asList("fire_user"))
//根据表前缀生成
.designatedTablePrefix(new ArrayList<>())
//根据表后缀生成
.designatedTableSuffix(new ArrayList<>())
//忽略表名
.ignoreTableName(ignoreTableName)
//忽略表前缀
.ignoreTablePrefix(ignorePrefix)
//忽略表后缀
.ignoreTableSuffix(ignoreSuffix).build();
}
}边栏推荐
- Scala基础【正则表达式、框架式开发原则】
- FinClip,助长智能电视更多想象空间
- SolidEdge ST8安装教程
- Kotlin - 扩展函数和运算符重载
- HCIP BGP实验报告
- 【LeetCode】最长公共子序列(动态规划)
- Pytest learn-setup/teardown
- End-to-End Lane Marker Detection via Row-wise Classification
- Use tf.image.resize() and tf.image.resize_with_pad() to resize images
- Take an example of a web worker
猜你喜欢

Creo 9.0二维草图的诊断:加亮开放端点

FinClip,助长智能电视更多想象空间

Cloud platform construction solutions

Another MySQL masterpiece published by Glacier (send the book at the end of the article)!!

Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"

Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素科研试剂

BMN: Boundary-Matching Network for Temporal Action Proposal Generation阅读笔记

Creo 9.0创建几何点

Deep integration of OPC UA and IEC61499 (1)

Creo 9.0二维草图的诊断:重叠几何
随机推荐
rosbridge-WSL2 && carla-win11
The salary of soft testers at each stage, come to Kangkang, how much can you get?
设置工作模式与环境(下):探查和收集信息
单例模式使用饿汉式和懒汉式创建一定安全?很多人不知
雅思大作文写作模版
Storage engine written by golang, based on b+ tree, mmap
Why do we need callbacks
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
射频芯片ATE测试从入门到放弃之参数测试
软件测试内卷严重,如何提升自己的竞争力呢?
伴随着元宇宙、web3.0等概念的兴起,数字人、数字场景等诸多数字化的形态开始出现
【day6】类与对象、封装、构造方法
Unity2021发布WebGL雾效消失问题
Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"
使用tf.image.resize() 和tf.image.resize_with_pad()调整图像大小
End-to-End Lane Marker Detection via Row-wise Classification
用队列模拟实现栈
Pytest learn-setup/teardown
响应式织梦模板除尘器类网站