Database document diagram

First, database support

  • MySQL
  • MariaDB
  • TIDB
  • Oracle
  • SqlServer
  • PostgreSQL
  • Cache DB

Second, the configuration

1. Pom files

Introduce SCREW core package, HikariCP database connection pool, HikariCP known as the most outstanding performance of database connection pool.

<! GroupId </groupId> <artifactId>screw-core</artifactId> The < version > 1.0.3 < / version > < / dependency > <! -- 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> Copies the codeCopy the code

2. Configure the data source

Configure data sources and set useInformationSchema to obtain tables annotation information.

Spring: a datasource: url: JDBC: mysql: / / 127.0.0.1:3306 / test? useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&&serverTimezone=Asia/Shanghai username: root password: 123456 driver-class-name: com.mysql.cj.jdbc.DriverCopy the code

Screw core configuration

Screw has two ways of execution, the first is poM file configuration and the other is code execution.

<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> The < version > 1.0.2 < / version > < dependencies > <! --mysql driver--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.18</version> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <version>3.4.5</version> </dependency> </dependencies> <configuration> <! --username--> <username>root</username> <! --password--> <password>123456</password> <! --driver--> <driverClassName>com.mysql.cj.jdbc.Driver</driverClassName> <! - the JDBC url - > < jdbcUrl > JDBC: mysql: / / 127.0.0.1:3306 / test < / jdbcUrl > <! <fileType>WORD</fileType> <! <fileOutputDir>C:\Users\Administrator\Desktop</fileOutputDir> <! False </openOutputDir> <! <produceType>freemarker</produceType> <! -- Description --> <description> Database document generation </description> <! -- Version --> <version>1.0</version> <! Executions > <execution> <phase>compile</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugins> </buildCopy the code

After configuration, double-click Maven project->clean -> Install -> SCREW and execute OK.

Insert a picture description here

The code generation is also very simple.

@SpringBootTest public class ScrewApplicationTests { @Autowired ApplicationContext applicationContext; @Test void contextLoads() { DataSource dataSourceMysql = applicationContext.getBean(DataSource.class); EngineConfig EngineConfig = EngineConfig. Builder () FileOutputDir ("D:/") // open the directory. OpenOutputDir (false) // fileType. FileType (enginefiletype.html) // generate template implementation .produceType(EngineTemplateType.freemarker).build(); Configuration config = configuration.builder ().version("1.0.3").description(" Generated document information description ") .dataSource(dataSourceMysql) .engineConfig(engineConfig) .produceConfig(getProcessConfig()) .build(); New DocumentationExecute(config).execute(); } public static ProcessConfig getProcessConfig() {List<String> ignoreTableName = Arrays.asList("a", "test_group"); List<String> ignorePrefix = array.asList ("a", "t"); List<String> ignoreSuffix = arrays. asList("_test", "czb_"); Return processConfig.Builder () // Specify table generation by name.designatedTablename (arrays.asList ("fire_user")) // Generate by table prefix .DesignatedTablePrefix (new ArrayList<>()) // Generates table suffixes based on.DesignatedTablesuffix (new ArrayList<>()) // Ignores table names IgnoreTableName (ignoreTableName) // Ignores the table prefixes. IgnoreTablePrefix (ignorePrefix) // Ignores the table suffix .ignoreTableSuffix(ignoreSuffix).build(); }} Copy the codeCopy the code

4. Document format

Screw has documents in HTML, DOC and MD formats.

Changes in code

.fileType(enginefiletype.html) Copies codeCopy the code

Or poM files

<fileType>MD</fileType>

Copy the code

DOC Document Style

The work documents

HTML Document Style

MD Document Style