当前位置:网站首页>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();
}
}
边栏推荐
- The sword refers to the offer question 22 - the Kth node from the bottom in the linked list
- utils 定时器
- 获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
- 3D 语义分割——2DPASS
- Golang Chapter 2: Program Structure
- Websocket multi-threaded sending message error TEXT_PARTIAL_WRITING--Use case of spin lock replacing synchronized exclusive lock
- The principle and use of AOSP CameraLatencyHistogram
- 3D Semantic Segmentation - 2DPASS
- 物联网新零售模式,引领购物新潮流
- log4j-slf4j-impl cannot be present with log4j-to-slf4j
猜你喜欢
【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
跨域的学习
First domestic open source framework 】 【 general cloud computing framework, any program can be made into cloud computing.
Code Casual Recording Notes_Dynamic Programming_416 Segmentation and Subsetting
Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"
用栈实现队列
ML之yellowbrick:基于titanic泰坦尼克是否获救二分类预测数据集利用yellowbrick对LoR逻辑回归模型实现可解释性(阈值图)案例
navicat 连接 mongodb 报错[13][Unauthorized] command listDatabases requires authentication
Pytest learn-setup/teardown
V8中的快慢数组(附源码、图文更易理解)
随机推荐
Creo 9.0二维草图的诊断:重叠几何
(PC+WAP)织梦模板螺钉手柄类网站
Research status of target detection at home and abroad
七夕活动浪漫上线,别让网络拖慢和小姐姐的开黑时间
最小化安装debian11
使用tf.image.resize() 和tf.image.resize_with_pad()调整图像大小
log4j-slf4j-impl cannot be present with log4j-to-slf4j
Create function report error, prompting DECLARE definition syntax problem
utlis thread pool
【day1】
藏宝计划TreasureProject(TPC)系统模式开发技术原理
Boss: There are too many systems in the company, can you realize account interoperability?
七夕?new一个对象
Embedded Systems: GPIO
用栈实现队列
【RYU】rest_router.py源码解析
Deep integration of OPC UA and IEC61499 (1)
override学习(父类和子类)
重发布实验报告
冰河又一MySQL力作出版(文末送书)!!