欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot整合screw實(shí)現(xiàn)數(shù)據(jù)庫(kù)文檔自動(dòng)生成的示例代碼

 更新時(shí)間:2020年09月22日 14:19:32   作者:周兆東  
這篇文章主要介紹了SpringBoot整合screw實(shí)現(xiàn)數(shù)據(jù)庫(kù)文檔自動(dòng)生成的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

有時(shí)候數(shù)據(jù)庫(kù)文檔需要整理,可是只能手動(dòng)的復(fù)制粘貼,心中一萬(wàn)只草泥馬奔騰而過(guò)。。。

screw

簡(jiǎn)潔好用的數(shù)據(jù)庫(kù)表結(jié)構(gòu)文檔生成工具。

1. 創(chuàng)建項(xiàng)目

1.1 pom.xml

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.freemarker</groupId>
  <artifactId>freemarker</artifactId>
  <version>2.3.30</version>
</dependency>

<dependency>
  <groupId>cn.smallbun.screw</groupId>
  <artifactId>screw-core</artifactId>
  <version>1.0.5</version>
</dependency>

1.2 新建工具類(lèi)DocumentConfig.java

/**
   * 文檔生成
   */
  static void documentGeneration() {
    //數(shù)據(jù)源
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
    hikariConfig.setJdbcUrl("jdbc:mysql://IP地址:3306/數(shù)據(jù)庫(kù)名稱(chēng)");
    hikariConfig.setUsername("用戶(hù)名");
    hikariConfig.setPassword("密碼");
    //設(shè)置可以獲取tables remarks信息
    hikariConfig.addDataSourceProperty("useInformationSchema", "true");
    hikariConfig.setMinimumIdle(2);
    hikariConfig.setMaximumPoolSize(5);
    DataSource dataSource = new HikariDataSource(hikariConfig);
    //生成配置
    EngineConfig engineConfig = EngineConfig.builder()
        //生成文件路徑
        .fileOutputDir("D:\\")
        //打開(kāi)目錄
        .openOutputDir(true)
        //文件類(lèi)型
        .fileType(EngineFileType.HTML)
        //生成模板實(shí)現(xiàn)
        .produceType(EngineTemplateType.freemarker)
        //自定義文件名稱(chēng)
        .fileName("test數(shù)據(jù)庫(kù)").build();

    //忽略表
    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()
        //指定生成邏輯、當(dāng)存在指定表、指定表前綴、指定表后綴時(shí),將生成指定表,其余表不生成、并跳過(guò)忽略表配置
        //根據(jù)名稱(chēng)指定表生成
        .designatedTableName(new ArrayList<>())
        //根據(jù)表前綴生成
        .designatedTablePrefix(new ArrayList<>())
        //根據(jù)表后綴生成
        .designatedTableSuffix(new ArrayList<>())
        //忽略表名
        .ignoreTableName(ignoreTableName)
        //忽略表前綴
        .ignoreTablePrefix(ignorePrefix)
        //忽略表后綴
        .ignoreTableSuffix(ignoreSuffix).build();
    //配置
    Configuration config = Configuration.builder()
        //版本
        .version("1.0.0")
        //描述
        .description("數(shù)據(jù)庫(kù)設(shè)計(jì)文檔生成")
        //數(shù)據(jù)源
        .dataSource(dataSource)
        //生成配置
        .engineConfig(engineConfig)
        //生成配置
        .produceConfig(processConfig)
        .build();
    //執(zhí)行生成
    new DocumentationExecute(config).execute();
  }

1.3 運(yùn)行該方法

1.4 第二種生成配置

1.4.1 先在application.yml里面配置數(shù)據(jù)庫(kù)連接信息:

spring:
 datasource:
  driver-class-name: com.mysql.cj.jdbc.Driver
  url: jdbc:mysql://IP地址:3306/數(shù)據(jù)庫(kù)名稱(chēng)
  username: 用戶(hù)名
  password: 密碼
  xa:
   properties:
    useInformationSchema: true

1.4.2 新建test方法

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.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

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

@SpringBootTest
public class ScrewApplicationTests {

  @Autowired
  ApplicationContext applicationContext;

  @Test
  void contextLoads() {
    DataSource dataSourceMysql = applicationContext.getBean(DataSource.class);

    // 生成文件配置
    EngineConfig engineConfig = EngineConfig.builder()
        // 生成文件路徑,自己mac本地的地址,這里需要自己更換下路徑
        .fileOutputDir("D:\\")
        // 打開(kāi)目錄
        .openOutputDir(false)
        // 文件類(lèi)型
        .fileType(EngineFileType.HTML)
        // 生成模板實(shí)現(xiàn)
        .produceType(EngineTemplateType.freemarker).build();

    // 生成文檔配置(包含以下自定義版本號(hào)、描述等配置連接)
    Configuration config = Configuration.builder()
        .version("1.0.0")
        .description("生成文檔信息描述")
        .dataSource(dataSourceMysql)
        .engineConfig(engineConfig)
        .produceConfig(getProcessConfig())
        .build();

    // 執(zhí)行生成
    new DocumentationExecute(config).execute();
  }


  /**
   * 配置想要生成的表+ 配置想要忽略的表
   * @return 生成表配置
   */
  public static ProcessConfig getProcessConfig(){
    // 忽略表名
    List<String> ignoreTableName = Arrays.asList("aa","test_group");
    // 忽略表前綴,如忽略a開(kāi)頭的數(shù)據(jù)庫(kù)表
    List<String> ignorePrefix = Arrays.asList("a","t");
    // 忽略表后綴
    List<String> ignoreSuffix = Arrays.asList("_test","czb_");

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

}

1.4.3 運(yùn)行test方法生成

GitHub代碼地址:

github.com/zhouzhaodong/springboot/tree/master/spring-boot-screw

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

相關(guān)文章

  • 詳解MybatisPlus集成nacos導(dǎo)致druid連接不上數(shù)據(jù)庫(kù)

    詳解MybatisPlus集成nacos導(dǎo)致druid連接不上數(shù)據(jù)庫(kù)

    這篇文章主要介紹了詳解MybatisPlus集成nacos導(dǎo)致druid連接不上數(shù)據(jù)庫(kù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • spring中IOC控制反轉(zhuǎn)依賴(lài)注入和new對(duì)象的區(qū)別說(shuō)明

    spring中IOC控制反轉(zhuǎn)依賴(lài)注入和new對(duì)象的區(qū)別說(shuō)明

    這篇文章主要介紹了spring中IOC控制反轉(zhuǎn)依賴(lài)注入和new對(duì)象的區(qū)別說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-02-02
  • Spring?Security實(shí)現(xiàn)基于RBAC的權(quán)限表達(dá)式動(dòng)態(tài)訪問(wèn)控制的操作方法

    Spring?Security實(shí)現(xiàn)基于RBAC的權(quán)限表達(dá)式動(dòng)態(tài)訪問(wèn)控制的操作方法

    這篇文章主要介紹了Spring?Security實(shí)現(xiàn)基于RBAC的權(quán)限表達(dá)式動(dòng)態(tài)訪問(wèn)控制,資源權(quán)限表達(dá)式動(dòng)態(tài)權(quán)限控制在Spring Security也是可以實(shí)現(xiàn)的,首先開(kāi)啟方法級(jí)別的注解安全控制,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-04-04
  • 詳談Spring是否支持對(duì)靜態(tài)方法進(jìn)行Aop增強(qiáng)

    詳談Spring是否支持對(duì)靜態(tài)方法進(jìn)行Aop增強(qiáng)

    這篇文章主要介紹了Spring是否支持對(duì)靜態(tài)方法進(jìn)行Aop增強(qiáng),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • spring boot 日志配置詳解

    spring boot 日志配置詳解

    本篇文章主要介紹了spring boot 日志配置 ,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-03-03
  • SpringBoot實(shí)現(xiàn)異步事件Event詳解

    SpringBoot實(shí)現(xiàn)異步事件Event詳解

    這篇文章主要介紹了SpringBoot實(shí)現(xiàn)異步事件Event詳解,異步事件的模式,通常將一些非主要的業(yè)務(wù)放在監(jiān)聽(tīng)器中執(zhí)行,因?yàn)楸O(jiān)聽(tīng)器中存在失敗的風(fēng)險(xiǎn),所以使用的時(shí)候需要注意,需要的朋友可以參考下
    2023-11-11
  • 解決mybatis-plus-boot-starter與mybatis-spring-boot-starter的錯(cuò)誤問(wèn)題

    解決mybatis-plus-boot-starter與mybatis-spring-boot-starter的錯(cuò)誤問(wèn)題

    本文主要講述了在使用MyBatis和MyBatis-Plus時(shí)遇到的綁定異常問(wèn)題,通過(guò)排查和總結(jié),作者發(fā)現(xiàn)使用MyBatis-Plus?Boot?Starter可以解決這個(gè)問(wèn)題,文章詳細(xì)對(duì)比了MyBatis-Plus?Boot?Starter和MyBatis?Spring?Boot?Starter的功能和使用場(chǎng)景
    2025-01-01
  • JSON,AJAX,Maven入門(mén)基礎(chǔ)

    JSON,AJAX,Maven入門(mén)基礎(chǔ)

    這篇文章主要介紹了JSON,AJAX和Maven基礎(chǔ),如何使用AJAX讀取Json數(shù)組里面的數(shù)據(jù),感興趣的小伙伴們可以參考一下,希望能夠幫助到你
    2021-07-07
  • SpringBoot中?Jackson?日期的時(shí)區(qū)和日期格式問(wèn)題解決

    SpringBoot中?Jackson?日期的時(shí)區(qū)和日期格式問(wèn)題解決

    因?yàn)樽罱?xiàng)目需要國(guó)際化,需要能夠支持多種國(guó)際化語(yǔ)言,目前需要支持三種(法語(yǔ)、英語(yǔ)、簡(jiǎn)體中文),這篇文章主要介紹了SpringBoot中?Jackson?日期的時(shí)區(qū)和日期格式問(wèn)題,需要的朋友可以參考下
    2022-12-12
  • java中struts2實(shí)現(xiàn)文件上傳下載功能

    java中struts2實(shí)現(xiàn)文件上傳下載功能

    這篇文章主要介紹了java中struts2實(shí)現(xiàn)文件上傳下載功能的方法,以實(shí)例形式分析了struts2文件上傳下載功能的實(shí)現(xiàn)技巧與相關(guān)問(wèn)題,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2016-05-05

最新評(píng)論