日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

數(shù)據(jù)庫界的swagger,連接數(shù)據(jù)庫直接生成數(shù)據(jù)庫文檔

 

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

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

二、配置

1、pom文件

引入screw核心包,HikariCP數(shù)據(jù)庫連接池,HikariCP號稱性能最出色的數(shù)據(jù)庫連接池。

<!-- screw核心 -->
<dependency>
    <groupId>cn.smallbun.screw</groupId>
    <artifactId>screw-core</artifactId>
    <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>

2、配置數(shù)據(jù)源

配置數(shù)據(jù)源,設(shè)置 useInformationSchema 可以獲取tables注釋信息。

spring.datasource.url=jdbc:mysql://192.168.1.5:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.xa.properties.useInformationSchema=true 

3、screw 核心配置

screw有兩種執(zhí)行方式,第一種是pom文件配置,另一種是代碼執(zhí)行。

<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>
            <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://192.168.1.5:3306/test</jdbcUrl>
                <!--生成文件類型-->
                <fileType>html</fileType>
                <!--打開文件輸出目錄-->
                <openOutputDir>false</openOutputDir>
                <!--生成模板-->
                <produceType>freemarker</produceType>
                <!--文檔名稱 為空時:將采用[數(shù)據(jù)庫名稱-描述-版本號]作為文檔名稱-->
                <!--<docName>測試文檔名稱</docName>-->
                <!--描述-->
                <description>數(shù)據(jù)庫文檔生成</description>
                <!--版本-->
                <version>${project.version}</version>
                <!--標題-->
                <title>fire數(shù)據(jù)庫文檔</title>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

配置完以后,在 maven project->screw 雙擊執(zhí)行ok。

數(shù)據(jù)庫界的swagger,連接數(shù)據(jù)庫直接生成數(shù)據(jù)庫文檔

pom執(zhí)行方式

代碼生成方式

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.Eng.NETemplateType;
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
class ScrewApplicationTests {

   @Autowired
   ApplicationContext applicationContext;

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

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

      // 生成文檔配置(包含以下自定義版本號、描述等配置連接)
      Configuration config = Configuration.builder()
            .version("1.0.3")
            .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開頭的數(shù)據(jù)庫表
      List<String> ignorePrefix = Arrays.asList("a","t");
      // 忽略表后綴
      List<String> ignoreSuffix = Arrays.asList("_test","czb_");

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

4、文檔格式

screw 有 HTML、DOC、MD 三種格式的文檔。

代碼中的修改

.fileType(EngineFileType.HTML)

或者pom文件

<fileType>MD</fileType>

 

數(shù)據(jù)庫界的swagger,連接數(shù)據(jù)庫直接生成數(shù)據(jù)庫文檔

數(shù)據(jù)庫文檔

5、鏈接

文檔工具 screw:https://gitee.com/leshalv/screw

分享到:
標簽:數(shù)據(jù)庫
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定