当前位置:网站首页>Jar a key generation document database
Jar a key generation document database
2022-08-03 23:22: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 The documentation will be generated in the directorydoc目录中, The generated document supports three HTML、WORD、MD

5、生成方式二:
添加pom
<!-- screw核心 螺丝钉 生成数据库文档-->
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency>测试类中添加如下方法,Execute this method
@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();
}
}边栏推荐
猜你喜欢

Zilliz 2023 Fall Campus Recruitment Officially Launched!

Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记

Pytest learn-setup/teardown

Quickly build a website with static files

Minimized installation of debian11

Click the icon in Canvas App to generate PDF and save it to Dataverse

Canvas App中点击图标生成PDF并保存到Dataverse中

Deep integration of OPC UA and IEC61499 (1)

Flutter教程之为什么 Flutter 是创业的最佳选择?

CAS:178744-28-0,mPEG-DSPE,DSPE-mPEG,甲氧基-聚乙二醇-磷脂酰乙醇胺供应
随机推荐
jav一键生成数据库文档
Kotlin - 扩展函数和运算符重载
重发布实验报告
Pytest学习-setup/teardown
Websocket multi-threaded sending message error TEXT_PARTIAL_WRITING--Use case of spin lock replacing synchronized exclusive lock
AOSP CameraLatencyHistogram的原理与使用
代码随想录笔记_动态规划_416分割等和子集
【LeetCode】最长回文子序列(动态规划)
ML之yellowbrick:基于titanic泰坦尼克是否获救二分类预测数据集利用yellowbrick对LoR逻辑回归模型实现可解释性(阈值图)案例
OPC UA 与IEC61499 深度融合(1)
V8中的快慢数组(附源码、图文更易理解)
Embedded Systems: Clocks
Analysys Analysis: The transaction scale of China's online retail B2C market in Q2 2022 will reach 2,344.47 billion yuan
Creo9.0 绘制中心线
Pytest learn-setup/teardown
Cloud platform construction solutions
藏宝计划TreasureProject(TPC)系统模式开发技术原理
2022/8/3 Exam Summary
With the rise of concepts such as metaverse and web3.0, many digital forms such as digital people and digital scenes have begun to appear.
Quickly build a website with static files