github项目地址:https://github.com/pingfangushi/screw
不需要下载github项目
有两种方法,一种写代码,一种用maven插件的方法,
那我们当然选择maven插件啦!
步骤一
在pom.xml文件中添加如下代码:
可以根据需求自己修改
<build>
<plugins>
<plugin>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-maven-plugin</artifactId>
<!-- 这里的版本号可以用最新的,我现在1.0.4就是最新的 -->
<version>1.0.4</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>123</password>
<!--driver-->
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<!--jdbc url-->
<jdbcUrl>jdbc:mysql://localhost:3306/user?serverTimezone=GMT%2B8</jdbcUrl>
<!--生成文件类型,有HTML WORD MD-->
<fileType>WORD</fileType>
<!--打开文件输出目录-->
<openOutputDir>false</openOutputDir>
<!--生成模板-->
<produceType>freemarker</produceType>
<!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
<fileName>测试文档名称</fileName>
<!--描述-->
<description>数据库文档生成</description>
<!--版本-->
<version>${project.version}</version>
<!--标题-->
<title>数据库文档</title>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
步骤二
这时候我们运行maven插件,方法如下
结果: