[Open Source] A Simple and Easy-to-Use Database Table Structure Documentation Generator Supporting Multiple Mainstream Databases
Open SourceProcess Management
![[Open Source] A Simple and Easy-to-Use Database Table Structure Documentation Generator Supporting Multiple Mainstream Databases](https://yy123.ink/api/img/1782587501869-u52cts.jpg)
1. Project Overview

An indispensable screw that never rusts in enterprise-level development.
screw (screw) English: [skruː] ~ A simple and easy-to-use database table structure documentation generator
2. Open Source License
Licensed under LGPL-3.0 open source protocol
3. Screenshots
Documentation Screenshots
- html


- word

- markdwon


4. Feature Overview
Author's Description
In enterprise-level development, we often spend a considerable amount of time writing database table structure documentation. Throughout my career, I have worked at several companies and observed the following situations regarding database documentation: either there is no documentation at all, or documentation exists but is entirely handwritten. During subsequent maintenance and development, developers must manually update the documentation, which is tedious. Missing even a single update can cause considerable trouble in future work, creating hidden problems for ourselves and those who follow. This inspired me to develop a plugin tool of my own. However, my early programming design experience was limited, and my skills were not yet sufficient to turn the idea into reality. As I gained more work experience and continuously expanded my knowledge, I finally started development in mid-March 2020 and completed the initial version in early April. I had planned to improve it further before making it open source, but due to a heavy workload and limited free time, development was put on hold. In June, frequent database design changes at work led me to use this plugin regularly. It saved me a great deal of time and solved many problems. With the limited spare time available, I began preparing it for open source release. On June 22, 2020, it was officially open-sourced. Everyone is welcome to use it, offer suggestions, and contribute.
Coming up with a name was surprisingly difficult. Fortunately, a flash of inspiration came to my clever little mind: how could I emphasize that it is small but important? Ever since childhood, I had learned about Lei Feng's spirit of being a dedicated screw. As quoted from Lei Feng's diary: Although a screw is tiny and a gear is small, without it, the entire machine cannot operate. Even if it is not entirely missing, a single loose screw or a slightly damaged gear can cause the machine to malfunction... I felt that the tool I had created embodied this spirit. Although it is small, development would be difficult without it. So I named it screw.
Features
- Simple, lightweight, and well-designed
- Multi-Database Support
- Multiple Documentation Formats
- Flexible Extensibility
- Custom Template Support
Database Support
- MySQL
- MariaDB
- TIDB
- Oracle
- SqlServer
- PostgreSQL
- Cache DB(2016)
- H2 (In Development)
- DB2 (In Development)
- HSQL (In Development)
- SQLite (In Development)
- HighGo (In Development)
- DM Database (In Development)
- Xugu (In Development)
- KingbaseES (In Development)
Documentation Generation Support
- html
- word
- markdown
5. Tech Stack
Usage
Standard Usage
- Add the Dependency
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>${lastVersion}</version>
</dependency>
- Write the Code
/**
* Document Generation
*/
void documentGeneration() {
//Data source
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/database");
hikariConfig.setUsername("root");
hikariConfig.setPassword("password");
//Enable retrieval of table remarks information
hikariConfig.addDataSourceProperty("useInformationSchema", "true");
hikariConfig.setMinimumIdle(2);
hikariConfig.setMaximumPoolSize(5);
DataSource dataSource = new HikariDataSource(hikariConfig);
//Generation configuration
EngineConfig engineConfig = EngineConfig.builder()
//Output file path
.fileOutputDir(fileOutputDir)
//Open output directory
.openOutputDir(true)
//File type
.fileType(EngineFileType.HTML)
//Template engine implementation
.produceType(EngineTemplateType.freemarker)
//Custom file name
.fileName("Custom File Name").build();
//Tables to ignore
ArrayList<String> ignoreTableName = new ArrayList<>();
ignoreTableName.add("test_user");
ignoreTableName.add("test_group");
//Table prefixes to ignore
ArrayList<String> ignorePrefix = new ArrayList<>();
ignorePrefix.add("test_");
//Table suffixes to ignore
ArrayList<String> ignoreSuffix = new ArrayList<>();
ignoreSuffix.add("_test");
ProcessConfig processConfig = ProcessConfig.builder()
//Specify the generation logic. When designated tables, table prefixes, or table suffixes are specified, only matching tables will be generated. All other tables will be skipped, and the ignore-table configuration will be bypassed.
//Generate tables by specified names
.designatedTableName(new ArrayList<>())
//Generate tables by prefixes
.designatedTablePrefix(new ArrayList<>())
//Generate tables by suffixes
.designatedTableSuffix(new ArrayList<>())
//Table names to ignore
.ignoreTableName(ignoreTableName)
//Table prefixes to ignore
.ignoreTablePrefix(ignorePrefix)
//Table suffixes to ignore
.ignoreTableSuffix(ignoreSuffix).build();
//Configuration
Configuration config = Configuration.builder()
//Version
.version("1.0.0")
//Description
.description("Database Design Documentation Generation")
//Data source
.dataSource(dataSource)
//Generation configuration
.engineConfig(engineConfig)
//Generation configuration
.produceConfig(processConfig)
.build();
//Execute generation
new DocumentationExecute(config).execute();
}
Maven Plugin
<build>
<plugins>
<plugin>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-maven-plugin</artifactId>
<version>${lastVersion}</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.20</version>
</dependency>
</dependencies>
<configuration>
<!-- Username -->
<username>root</username>
<!-- Password -->
<password>password</password>
<!-- Driver -->
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<!-- JDBC URL -->
<jdbcUrl>jdbc:mysql://127.0.0.1:3306/xxxx</jdbcUrl>
<!-- Generated file type -->
<fileType>HTML</fileType>
<!-- Open file output directory -->
<openOutputDir>false</openOutputDir>
<!-- Generation template -->
<produceType>freemarker</produceType>
<!-- Document name. If empty, [Database Name-Description-Version] will be used as the document name -->
<fileName>Test Document Name</fileName>
<!-- Description -->
<description>Database Documentation Generation</description>
<!-- Version -->
<version>${project.version}</version>
<!-- Title -->
<title>Database Documentation</title>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Extension Module
POJO Generation Feature
Function Introduction
The POJO generation feature is an extension module developed based on Screw. It is currently in the early stages of development. In daily development, after requirements analysis and modeling, developers typically create tables in the database before proceeding with code development. The POJO generation feature can help save repetitive work at this stage. It allows you to generate corresponding Java POJO objects directly from the database. This makes subsequent modifications and development much more convenient.
Database Support
- MySQL
Usage
- Add the Dependency
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-extension</artifactId>
<version>${lastVersion}</version>
</dependency>
- Write the Code
/**
* POJO Generation
*/
void pojoGeneration() {
// Data source
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/screw");
hikariConfig.setUsername("screw");
hikariConfig.setPassword("screw");
// Enable retrieval of table remarks information
hikariConfig.addDataSourceProperty("useInformationSchema", "true");
hikariConfig.setMinimumIdle(2);
hikariConfig.setMaximumPoolSize(5);
DataSource dataSource = new HikariDataSource(hikariConfig);
ProcessConfig processConfig = ProcessConfig.builder()
// Specify the generation rules. When designated tables, table prefixes, or table suffixes are specified, only matching tables will be generated. All other tables will be skipped, and the ignore table configuration will be bypassed.
// Generate tables by specified names
.designatedTableName(new ArrayList<>())
// Generate tables by prefix
.designatedTablePrefix(new ArrayList<>())
// Generate tables by suffix
.designatedTableSuffix(new ArrayList<>()).build();
// Configure POJO generation settings
PojoConfiguration config = new PojoConfiguration();
// Set the file storage path
config.setPath("/cn/smallbun/screw/");
// Set the package name
config.setPackageName("cn.smallbun.screw");
// Specify whether to use Lombok
config.setUseLombok(false);
// Set the data source
config.setDataSource(dataSource);
// Set the naming strategy
config.setNameStrategy(new HumpNameStrategy());
// Set the table filtering rules
config.setProcessConfig(processConfig);
// Execute generation
new PojoExecute(config).execute();
}
下载地址 免费
评论