Brief introduction:

In enterprise-level development, we often have to write database table structure document time to pay, in order to save time, SCREW should be shipped out.Copy the code

Features:

1. Simple, lightweight, well-designed 2. Multi-database support 3. Flexible extension 5. Supports custom templatesCopy the code

Database support:

1.MySQL
2.MariaDB
3.TIDB
4.Oracle
5.SqlServer
6.PostgreSQL
7.Cache DB
Copy the code

Document generation support:

1.html
2.word
3.markdwon
Copy the code

Document screenshot:

HTML

WORD

MARKDOWN

Usage:

The ordinary way

1. Introduce dependencies

      <dependency>
      <groupId>cn.smallbun.screw</groupId>
      <artifactId>screw-core</artifactId>
      <version>${lastVersion}</version>
      </dependency>
      
Copy the code

2. Write code

Void documentGeneration() {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"); / / set access tables hikariConfig. Few information addDataSourceProperty (" useInformationSchema ", "true"); hikariConfig.setMinimumIdle(2); hikariConfig.setMaximumPoolSize(5); DataSource dataSource = new HikariDataSource(hikariConfig); EngineConfig EngineConfig = EngineConfig. Builder () // Generate file path.fileOutputDir (fileOutputDir) // open directory OpenOutputDir (true) / / file type. The fileType (EngineFileType. HTML) / / generate template implementation. ProduceType (EngineTemplateType. Freemarker) .filename (" custom fileName ").build(); // Ignore table ArrayList<String> ignoreTableName = new ArrayList<>(); ignoreTableName.add("test_user"); ignoreTableName.add("test_group"); ArrayList<String> ignorePrefix = new ArrayList<>(); ignorePrefix.add("test_"); ArrayList<String> ignoreSuffix = new ArrayList<>(); ignoreSuffix.add("_test"); ProcessConfig ProcessConfig = processconfig.builder () ProcessConfig ProcessConfig = processconfig.builder () DesignatedTableName (new ArrayList<>()) // Generated by table prefix. DesignatedTablePrefix (new ArrayList<>()) DesignatedTableSuffix (New ArrayList<>()) // Ignores table names. IgnoreTableName (ignoreTableName) // Ignores table prefixes .ignoreTablePrefix(ignorePrefix) // Ignore the table suffix. IgnoreTableSuffix (ignoreSuffix).build(); Configuration config = configuration.builder () // version.version ("1.0.0") // description.description (" database design document generation ") // Data source .datasource (dataSource) // Generate configuration.engineconfig (engineConfig) // generate configuration.produceconfig (processConfig).build(); New DocumentationExecute(config).execute();Copy the code

}

MAVEN plugin form

<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> <! - the JDBC url - > < jdbcUrl > JDBC: mysql: / / 127.0.0.1:3306 / XXXX < / jdbcUrl > <! <fileType>HTML</fileType> <! False </openOutputDir> <! <produceType>freemarker</produceType> <! -- Empty document name: [database name-description-version number] will be used as the document name --> <fileName> Test document name </fileName> <! -- Description --> <description> Database document generation </description> <! --> <version>${project.version}</version> <! Executions > <execution> <phase>compile</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>Copy the code