最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot集成screw實(shí)現(xiàn)數(shù)據(jù)庫文檔生成的代碼示例

 更新時間:2024年07月25日 08:38:16   作者:HBLOG  
數(shù)據(jù)庫設(shè)計文檔是項(xiàng)目技術(shù)文檔的重要組成部分,Screw 是一款開源的數(shù)據(jù)庫文檔生成工具,它支持多種數(shù)據(jù)庫類型,并能生成豐富格式的文檔,本文將通過一個實(shí)際的例子,展示如何使用 Spring Boot 集成 Screw 生成數(shù)據(jù)庫設(shè)計文檔

1.什么是screw?

在企業(yè)級開發(fā)中、我們經(jīng)常會有編寫數(shù)據(jù)庫表結(jié)構(gòu)文檔的時間付出,從業(yè)以來,待過幾家企業(yè),關(guān)于數(shù)據(jù)庫表結(jié)構(gòu)文檔狀態(tài):要么沒有、要么有、但都是手寫、后期運(yùn)維開發(fā),需要手動進(jìn)行維護(hù)到文檔中,很是繁瑣、如果忘記一次維護(hù)、就會給以后工作造成很多困擾、無形中制造了很多坑留給自己和后人

數(shù)據(jù)庫支持

  • MySQL
  • MariaDB
  • TIDB
  • Oracle
  • SqlServer
  • PostgreSQL
  • Cache DB(2016)
  • H2 (開發(fā)中)
  • DB2 (開發(fā)中)
  • HSQL (開發(fā)中)
  • SQLite(開發(fā)中)

2.環(huán)境準(zhǔn)備

參考之前springboot對接mysql的教程里面的mysql環(huán)境搭建 http://www.liuhaihua.cn/archives/710165.html

3.代碼工程

實(shí)驗(yàn)?zāi)康?/h3>

生成mysql數(shù)據(jù)庫的word文檔

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>springboot-demo</artifactId>
        <groupId>com.et</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>Screw</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cn.smallbun.screw</groupId>
            <artifactId>screw-core</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>
    </dependencies>
</project>

生成類

package com.et.screw;

import cn.smallbun.screw.core.Configuration;
import cn.smallbun.screw.core.engine.EngineConfig;
import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType;
import cn.smallbun.screw.core.execute.DocumentationExecute;
import cn.smallbun.screw.core.process.ProcessConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SpringBootApplication
public class Application implements ApplicationRunner {

    @Autowired
    ApplicationContext applicationContext;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {

        DataSource dataSourceMysql = applicationContext.getBean(DataSource.class);

        //模板引擎配置 生成文件配置
        EngineConfig engineConfig = EngineConfig.builder()
                // 生成文件路徑
                .fileOutputDir("D://tmp/")
                // 打開目錄
                .openOutputDir(false)
                // 文件類型
                .fileType(EngineFileType.WORD)
                // 生成模板實(shí)現(xiàn)
                .produceType(EngineTemplateType.freemarker).build();

        // 生成文檔配置(包含以下自定義版本號、描述等配置連接),文檔名稱拼接:數(shù)據(jù)庫名_描述_版本.擴(kuò)展名
        Configuration config = Configuration.builder()
                .title("數(shù)據(jù)庫文檔")
                // 版本號
                .version("1.0.0")
                // 描述
                .description("數(shù)據(jù)庫設(shè)計文檔")
                // 數(shù)據(jù)源
                .dataSource(dataSourceMysql)
                // 模板引擎配置
                .engineConfig(engineConfig)
                // 加載配置:想要生成的表、想要忽略的表
                .produceConfig(getProcessConfig())
                .build();
        // 執(zhí)行生成
        new DocumentationExecute(config).execute();
    }

    /**
     * 配置想要生成的表+ 配置想要忽略的表
     *
     * @return 生成表配置
     */
    public static ProcessConfig getProcessConfig() {
        // 忽略表名
        List<String> ignoreTableName = Arrays.asList("");

        return ProcessConfig.builder()
                //根據(jù)名稱指定表生成
                .designatedTableName(new ArrayList<>())
                //根據(jù)表前綴生成
                .designatedTablePrefix(new ArrayList<>())
                //根據(jù)表后綴生成
                .designatedTableSuffix(new ArrayList<>())
                //忽略表名
                .ignoreTableName(ignoreTableName)
                .build();
    }

}

application.properties

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/jwordpress?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456

以上只是一些關(guān)鍵代碼,所有代碼請參見下面代碼倉庫

代碼倉庫

4.測試

啟動Spring boot Application,在D://tmp/查看生成的文件

5.引用

https://gitee.com/leshalv/screw

到此這篇關(guān)于SpringBoot集成screw實(shí)現(xiàn)數(shù)據(jù)庫文檔生成的代碼示例的文章就介紹到這了,更多相關(guān)SpringBoot screw數(shù)據(jù)庫文檔生成內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java設(shè)計優(yōu)化之單例模式

    java設(shè)計優(yōu)化之單例模式

    這篇文章主要為大家詳細(xì)介紹了java設(shè)計優(yōu)化中的單例模式,深入學(xué)習(xí)java單例模式,感興趣的朋友可以參考一下
    2016-03-03
  • 使用MAT進(jìn)行JVM內(nèi)存分析實(shí)例

    使用MAT進(jìn)行JVM內(nèi)存分析實(shí)例

    這篇文章主要介紹了使用MAT進(jìn)行JVM內(nèi)存分析實(shí)例,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Java文件上傳的多種實(shí)現(xiàn)方式

    Java文件上傳的多種實(shí)現(xiàn)方式

    文章主要介紹了文件上傳接收接口的使用方法,包括獲取文件信息、創(chuàng)建文件夾、保存文件到本地的兩種方法,以及如何使用Postman進(jìn)行接口調(diào)用
    2025-01-01
  • Idea?編譯并運(yùn)行?Spark?3.1.1?源碼的方法

    Idea?編譯并運(yùn)行?Spark?3.1.1?源碼的方法

    這篇文章主要介紹了Idea?編譯并運(yùn)行?Spark?3.1.1源碼,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-11-11
  • Java 8中Collectors.toMap空指針異常源碼解析

    Java 8中Collectors.toMap空指針異常源碼解析

    這篇文章主要為大家介紹了Java 8中Collectors.toMap空指針異常源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • Java加權(quán)負(fù)載均衡策略實(shí)現(xiàn)過程解析

    Java加權(quán)負(fù)載均衡策略實(shí)現(xiàn)過程解析

    這篇文章主要介紹了Java加權(quán)負(fù)載均衡策略實(shí)現(xiàn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-03-03
  • spring框架cacheAnnotation緩存注釋聲明解析

    spring框架cacheAnnotation緩存注釋聲明解析

    這篇文章主要介紹了spring框架中cacheAnnotation注釋聲明緩存解析示例有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2021-10-10
  • springboot?neo4j的配置代碼

    springboot?neo4j的配置代碼

    小編最近的工作中遇到了一些知識圖譜的工作,自然就用到了圖數(shù)據(jù)庫,這一NoSQL?數(shù)據(jù)庫可以很好的展示節(jié)點(diǎn)之間的關(guān)聯(lián)關(guān)系,對于一些圖譜的關(guān)系操作是很好的選擇,下面來介紹下?Springboot?配置Neo4J的問題
    2021-12-12
  • Java swing實(shí)現(xiàn)酒店管理系統(tǒng)

    Java swing實(shí)現(xiàn)酒店管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了Java swing實(shí)現(xiàn)酒店管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-02-02
  • Java多態(tài)到底都有啥好處

    Java多態(tài)到底都有啥好處

    Java中的多態(tài)性有兩種類型:編譯時多態(tài)(靜態(tài)綁定)和運(yùn)行時多態(tài)(動態(tài)綁定)。方法重載是靜態(tài)多態(tài)的一個例子,而方法重寫是動態(tài)多態(tài)的一個例子,接下來通過本文給大家分享Java多態(tài)到底教了我干啥?有啥好處,一起了解下吧
    2021-05-05

最新評論

方城县| 晋中市| 绩溪县| 梅河口市| 石屏县| 壤塘县| 永和县| 利津县| 永善县| 乐业县| 东乌珠穆沁旗| 葵青区| 长岛县| 资溪县| 济南市| 云龙县| 巴彦淖尔市| 钟祥市| 海原县| 平遥县| 营山县| 宿迁市| 融水| 定襄县| 葵青区| 磐石市| 卢龙县| 米脂县| 子洲县| 苏尼特右旗| 西峡县| 贵南县| 仪陇县| 浮梁县| 靖州| 夹江县| 寻甸| 阿坝| 辽阳市| 正蓝旗| 淮南市|