自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

實用!一鍵生成數據庫文檔,堪稱數據庫界的Swagger

數據庫 其他數據庫
為了不重復 CV 操作,抱著一絲希望開始在GitHub里找,看看有沒有什么工具可以用,結果就真的發(fā)現了寶藏,screw(螺絲釘),居然可以生成數據庫文檔,優(yōu)秀啊~。

最近部門訂單業(yè)務調整,收攏其他業(yè)務線的下單入口,做個統一大訂單平臺。需要梳理各業(yè)務線的數據表,但每個業(yè)務線庫都有近百張和訂單相關的表,挨個表一個一個字段的弄腦瓜子嗡嗡的。

為了不重復 CV 操作,抱著一絲希望開始在GitHub里找,看看有沒有什么工具可以用,結果就真的發(fā)現了寶藏,screw(螺絲釘),居然可以生成數據庫文檔,優(yōu)秀啊~。

數據庫文檔圖

一、數據庫支持

    MySQL

    MariaDB

    TIDB

    Oracle

    SqlServer

    PostgreSQL

    Cache DB

二、配置

1、pom文件

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

  1. <!-- screw核心 -->  
  2. <dependency>  
  3.     <groupId>cn.smallbun.screw</groupId>  
  4.     <artifactId>screw-core</artifactId>  
  5.     <version>1.0.3</version>  
  6. </dependency>  
  7. <!-- HikariCP -->  
  8. <dependency>  
  9.     <groupId>com.zaxxer</groupId>  
  10.     <artifactId>HikariCP</artifactId>  
  11.     <version>3.4.5</version>  
  12. </dependency>  
  13. <!--mysql driver-->  
  14. <dependency>  
  15.     <groupId>mysql</groupId>  
  16.     <artifactId>mysql-connector-java</artifactId>  
  17.     <version>8.0.20</version>  
  18. </dependency> 

2、配置數據源

配置數據源,設置 useInformationSchema 可以獲取tables注釋信息。 

  1. spring.datasource.url=jdbc:mysql://45.93.1.5:3306/fire?useUnicode=true&characterEncoding=UTF-8&useSSL=false  
  2. spring.datasource.username=root  
  3. spring.datasource.password=123456  
  4. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver  
  5. spring.datasource.xa.properties.useInformationSchema=true  

3、screw 核心配置

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

  1.  <build>  
  2.     <plugins>  
  3.         <plugin>  
  4.             <groupId>org.springframework.boot</groupId>  
  5.             <artifactId>spring-boot-maven-plugin</artifactId>  
  6.         </plugin>  
  7.         <plugin> 
  8.              <groupId>cn.smallbun.screw</groupId>  
  9.             <artifactId>screw-maven-plugin</artifactId>  
  10.             <version>1.0.3</version>  
  11.             <dependencies>  
  12.                 <!-- HikariCP -->  
  13.                 <dependency> 
  14.                     <groupId>com.zaxxer</groupId>  
  15.                     <artifactId>HikariCP</artifactId>  
  16.                     <version>3.4.5</version>  
  17.                 </dependency>  
  18.                 <!--mysql driver-->  
  19.                 <dependency>  
  20.                     <groupId>mysql</groupId>  
  21.                     <artifactId>mysql-connector-java</artifactId>  
  22.                     <version>8.0.20</version>  
  23.                 </dependency>  
  24.             </dependencies>  
  25.             <configuration> 
  26.                  <!--username-->  
  27.                 <username>root</username>  
  28.                 <!--password-->  
  29.                 <password>123456</password>  
  30.                 <!--driver-->  
  31.                 <driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>  
  32.                 <!--jdbc url-->  
  33.                 <jdbcUrl>jdbc:mysql://41.92.6.5:3306/fire</jdbcUrl>  
  34.                 <!--生成文件類型-->  
  35.                 <fileType>HTML</fileType>  
  36.                 <!--打開文件輸出目錄-->  
  37.                 <openOutputDir>false</openOutputDir> 
  38.                  <!--生成模板-->  
  39.                 <produceType>freemarker</produceType>  
  40.                 <!--文檔名稱 為空時:將采用[數據庫名稱-描述-版本號]作為文檔名稱-->  
  41.                 <!--<docName>測試文檔名稱</docName>-->  
  42.                 <!--描述-->  
  43.                 <description>數據庫文檔生成</description>  
  44.                 <!--版本-->  
  45.                 <version>${project.version}</version>  
  46.                 <!--標題-->  
  47.                 <title>fire數據庫文檔</title>  
  48.             </configuration>  
  49.             <executions>  
  50.                 <execution>  
  51.                     <phase>compile</phase>  
  52.                     <goals>  
  53.                         <goal>run</goal>  
  54.                     </goals>  
  55.                 </execution>  
  56.             </executions>  
  57.         </plugin>  
  58.     </plugins>  
  59. </build> 

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

運行方式

代碼生成方式也非常簡單。 

  1. @SpringBootTest  
  2. public class ScrewApplicationTests {  
  3.     @Autowired  
  4.     ApplicationContext applicationContext;  
  5.     @Test  
  6.     void contextLoads() {  
  7.         DataSource dataSourceMysql = applicationContext.getBean(DataSource.class);  
  8.         // 生成文件配置  
  9.         EngineConfig engineConfig = EngineConfig.builder()  
  10.                 // 生成文件路徑,自己mac本地的地址,這里需要自己更換下路徑  
  11.                 .fileOutputDir("D:/")  
  12.                 // 打開目錄  
  13.                 .openOutputDir(false) 
  14.                  // 文件類型  
  15.                 .fileType(EngineFileType.HTML)  
  16.                 // 生成模板實現  
  17.                 .produceType(EngineTemplateType.freemarker).build();  
  18.         // 生成文檔配置(包含以下自定義版本號、描述等配置連接)  
  19.         Configuration config = Configuration.builder()  
  20.                 .version("1.0.3")  
  21.                 .description("生成文檔信息描述")  
  22.                 .dataSource(dataSourceMysql)  
  23.                 .engineConfig(engineConfig)  
  24.                 .produceConfig(getProcessConfig())  
  25.                 .build();  
  26.         // 執(zhí)行生成  
  27.         new DocumentationExecute(config).execute();  
  28.     }  
  29.     /** 
  30.       * 配置想要生成的表+ 配置想要忽略的表  
  31.      *  
  32.      * @return 生成表配置  
  33.      */  
  34.     public static ProcessConfig getProcessConfig() {  
  35.         // 忽略表名  
  36.         List<String> ignoreTableName = Arrays.asList("a", "test_group");  
  37.         // 忽略表前綴,如忽略a開頭的數據庫表  
  38.         List<String> ignorePrefix = Arrays.asList("a", "t");  
  39.         // 忽略表后綴  
  40.         List<String> ignoreSuffix = Arrays.asList("_test", "czb_");  
  41.         return ProcessConfig.builder()  
  42.                 //根據名稱指定表生成  
  43.                 .designatedTableName(Arrays.asList("fire_user"))  
  44.                 //根據表前綴生成  
  45.                 .designatedTablePrefix(new ArrayList<>())  
  46.                 //根據表后綴生成  
  47.                 .designatedTableSuffix(new ArrayList<>())  
  48.                 //忽略表名  
  49.                 .ignoreTableName(ignoreTableName)  
  50.                 //忽略表前綴 
  51.                  .ignoreTablePrefix(ignorePrefix)  
  52.                 //忽略表后綴  
  53.                 .ignoreTableSuffix(ignoreSuffix).build();  
  54.     }  

4、文檔格式

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

代碼中的修改 

  1. .fileType(EngineFileType.HTML) 

或者pom文件 

  1. <fileType>MD</fileType> 

DOC文檔樣式

DOC文檔

HTML文檔樣式

HTML文檔

MD文檔樣式

MD文檔 

 

責任編輯:龐桂玉 來源: Hollis
相關推薦

2020-12-24 10:20:43

文檔工具語言

2010-05-07 14:29:45

Unix--Tripw

2021-05-10 09:22:44

.NET數據庫項目

2024-08-13 10:36:25

SpringScrew數據庫

2011-05-13 13:54:02

數據庫文檔數據庫

2016-08-23 13:35:22

MVCEFNuGet

2021-06-30 22:03:05

數據庫交付設計

2011-08-22 16:08:46

IOS開發(fā)數據庫

2025-01-03 08:13:08

2024-10-28 16:31:03

2019-05-21 22:56:08

阿里云數據庫PolarDB

2024-03-13 07:26:23

2023-09-13 06:59:07

2023-03-29 07:02:46

開源項目工具

2011-08-10 15:46:29

數據庫

2010-04-15 15:06:19

Oracle數據庫

2010-04-14 17:29:33

Oracle數據庫

2011-05-13 09:42:21

2013-11-29 09:58:27

巨彬軟件NoSQL文檔型數據庫

2022-11-14 18:23:06

亞馬遜
點贊
收藏

51CTO技術棧公眾號