1、创建一个SpringBoot项目(本人使用的是IntelliJ IDEA 2020.1 x64)

  • 最佳简单的项目配置如下:

2、添加相关依赖

<!--screw依赖-->
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency> <!--解决连接oracle中文乱码-->
<dependency>
<groupId>cn.easyproject</groupId>
<artifactId>orai18n</artifactId>
<version>12.1.0.2.0</version>
</dependency>

3、连接数据库配置

#screw支持的数据库:MySQL、MariaDB、TIDB、Oracle、SqlServer、PostgreSQL、Cache DB(2016)

spring.datasource.url=jdbc:oracle:thin:@自填服务器地址:1521:库名
spring.datasource.username=XXX
spring.datasource.password=XXX
spring.datasource.xa.properties.useInformationSchema=true

4、脚本主要内容

  • 创建一个test类运行即可,代码如下:

package com.sinby.demo; 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 org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext; import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; @SpringBootTest
class DemoApplicationTests { @Autowired
ApplicationContext applicationContext; @Test
void contextLoads() {
DataSource dataSourceMysql = applicationContext.getBean(DataSource.class); // 生成文件配置
EngineConfig engineConfig = EngineConfig.builder()
// 生成文件路径(可自定义)
.fileOutputDir("F:/XXX")
// 打开目录
.openOutputDir(false)
//生成文件名(可自定义)
.fileName("tablefile")
// 文件类型 .HTML .WORD .MARKDOWN
.fileType(EngineFileType.WORD)
// 生成模板实现
.produceType(EngineTemplateType.freemarker)
.build(); // 生成文档配置(包含以下自定义版本号、描述等配置连接)
Configuration config = Configuration.builder()
.version("1.0.1") //可自定义
.description("某某数据库中文文档") //可自定义
.dataSource(dataSourceMysql)
.engineConfig(engineConfig)
.produceConfig(getProcessConfig())
.build(); // 执行生成
new DocumentationExecute(config).execute();
} /**
* 配置想要生成的表+ 配置想要忽略的表
* @return 生成表配置
*/
public static ProcessConfig getProcessConfig(){
// 忽略表名
List<String> ignoreTableName = Arrays.asList("aa","test_group"); // 忽略表前缀,如忽略a开头的数据库表
List<String> ignorePrefix = Arrays.asList("T_"); //,"t" // 忽略表后缀
List<String> ignoreSuffix = Arrays.asList("_test","czb_"); return ProcessConfig.builder()
//根据名称指定表生成
.designatedTableName(new ArrayList<>())
//根据表前缀生成
.designatedTablePrefix(new ArrayList<>())
//根据表后缀生成
.designatedTableSuffix(new ArrayList<>())
//忽略表名
.ignoreTableName(ignoreTableName)
//忽略表前缀
.ignoreTablePrefix(ignorePrefix).build();
//忽略表后缀
.ignoreTableSuffix(ignoreSuffix).build();
} }

5、参考

官网教程:SpringBoot整合screw生成数据库文档

最新文章

  1. LCQCL
  2. hangfire+bootstrap ace 模板实现后台任务管理平台
  3. C语言用面向对象的思想写贪吃蛇
  4. Arduino101学习笔记(六)&mdash;&mdash; 高级IO
  5. (转载)iOS系统Crash文件分析方法
  6. hdu 5100 n*n棋盘放k*1长方条最多覆盖面积
  7. POJ2226 Muddy Fields 二分匹配 最小顶点覆盖 好题
  8. ganymed-ssh2使用
  9. 如何将CELERY放到后台执行?
  10. c语言的label后面不能直接跟变量申明
  11. js打开新的链接
  12. freemaker
  13. thinkphp 5.0 模块设计
  14. Struts(十五):主题
  15. Android图片setBackgroundResource和setImageResource的区别
  16. Codeforces 229E Gifts 概率dp (看题解)
  17. CSS文本超出指定行数省略显示
  18. 重写TreeMap的compare方法处理配置表
  19. T-SQL语句1
  20. 查询set、dict、dict.keys()的速度对比

热门文章

  1. 分布式事务 | 使用 dotnetcore/CAP 的本地消息表模式
  2. Spring中常见的注解
  3. MD5在Python中的简单使用
  4. visual studio(vs2017、vs2019)离线安装包下载、制作
  5. C语言的输入格式
  6. 一篇文章带你弄懂Kerberos的设计思路
  7. 关于Powerlink和EtherCAT的对比
  8. 微信小程序 添加域名
  9. HACLABS: NO_NAME
  10. (五)REDIS-哨兵与集群