数据表文档导出 两种方式 

maven  的插件模式导出  

在maven  的pom文件中加入代码 

            <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.20</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <!--username-->
                    <username>root</username>
                    <!--password-->
                    <password>123456</password>
                    <!--driver-->
                    <driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
                    <!--jdbc url-->
                    <jdbcUrl>jdbc:mysql://10.10.2.23:3306/tony-flowable?serverTimezone=UTC</jdbcUrl>
                    <!--生成文件类型-->
                    <fileType>WORD</fileType>
                    <!--打开文件输出目录-->
                    <openOutputDir>false</openOutputDir>
                    <!--生成模板-->
                    <produceType>freemarker</produceType>
                    <!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
                    <!--<docName>测试文档名称</docName>-->
                    <!--描述-->
                    <description>flowable</description>
                    <!--版本-->
                    <version>${project.version}</version>
                    <!--标题-->
                    <title>医保新处方数据库文档</title>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
View Code

然后更新maven  

在maven的插件中点击运行screw,如下 

方式二  ,代码编写导出

  

class ScrewdemoApplicationTests {
 
    @Autowired
    ApplicationContext applicationContext;
 
    /** 
     * @description:  screw快速生成数据库文档
     
     * @return: void 
     * @author: Fariy
     * @date: 2020/9/4 
     */ 
    
    @Test
    void contextLoads() {
        DataSource dataSource = applicationContext.getBean(DataSource.class);
 
        // 1、生成文件配置
        EngineConfig engineConfig = EngineConfig.builder()
                //生成文件路径(本地路径)
                .fileOutputDir("/Users/Fariy/Documents/doc")
                //打开目录
                .openOutputDir(false)
                //文件类型( ".html"、".doc"、".md")
                .fileType(EngineFileType.HTML)
                //生成模板实现
                .produceType(EngineTemplateType.freemarker).build();
 
        // 忽略表名
        List<String> ignoreTableName = Arrays.asList("aa","test_group");
        // 忽略表前缀
        List<String> ignorePrefix = Collections.singletonList("czb_");
        // 忽略表后缀å
        List<String> ignoreSuffix = Arrays.asList("_test","_test1");
 
        // 2、配置想要忽略的表
        ProcessConfig processConfig = ProcessConfig.builder()
                .ignoreTableName(ignoreTableName)
                .ignoreTablePrefix(ignorePrefix)
                .ignoreTableSuffix(ignoreSuffix)
                .build();
 
        // 3、生成文档配置(包含以下自定义版本号、描述等配置连接)
        Configuration config = Configuration.builder()
                .version("1.0.1")
                .description("数据库设计文档生成")
                .dataSource(dataSource)
                .engineConfig(engineConfig)
                .produceConfig(processConfig).build();
 
        // 4、执行生成
        new DocumentationExecute(config).execute();
    }
 
}

 

posted on 2023-09-06 15:50  JonRain0625  阅读(94)  评论(0编辑  收藏  举报