当前位置:网站首页>学习使用代码生成美观的接口文档!!!
学习使用代码生成美观的接口文档!!!
2022-07-06 16:51:00 【Gettler•Main】
编写美观的接口文档
Controller层:导出Swagger文档
点击这里

出现下图所示

ctrl + a , ctrl + c复制全部后打开DocWay
点击新增,导入

选择导入Swagger,点击粘贴Swagger内容,将刚才复制的一大堆数据粘贴进来,点击导入

打开新增的项目

右上角的更多功能中选择导出项目便可以导出离线的接口文档啦

非常美观

Service层:使用Idea生成JavaDoc
打开idea,在这里生成JavaDoc

-encoding UTF-8 -charset UTF-8
点击生成即可

打开index.html,文档如下

数据库:Screw
添加依赖
<!-- 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>
编写测试类
package com.gettler.oa_team05.DataBaseOutput;
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 com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.Test;
import java.util.ArrayList;
public class DataSourceOutDemo {
@Test
public void test() {
// DataSource dataSourceMysql = SpringContextUtil.getBean(DataSource.class);
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://localhost:3306/oa_team05?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8");
hikariConfig.setUsername("root");
hikariConfig.setPassword("73748156");
HikariDataSource dataSourceMysql = new HikariDataSource(hikariConfig);
// 生成文件配置
EngineConfig engineConfig = EngineConfig.builder()
// 生成文件路径
.fileOutputDir("D:/")
// 打开目录
.openOutputDir(true)
// 文件类型
.fileType(EngineFileType.HTML)
// 生成模板实现
.produceType(EngineTemplateType.freemarker).build();
// 生成文档配置(包含以下自定义版本号、描述等配置连接)
Configuration config = Configuration.builder().version("V1").description("数据库文档").dataSource(dataSourceMysql).engineConfig(engineConfig).produceConfig(getProcessConfig()).build();
// 执行生成
new DocumentationExecute(config).execute();
}
/** * 配置想要生成的表+ 配置想要忽略的表 * * @return 生成表配置 */
public static ProcessConfig getProcessConfig() {
// // 忽略表名
// List<String> ignoreTableName = Arrays.asList("dept", "dept1");
// // 忽略表前缀,如忽略a开头的数据库表
// List<String> ignorePrefix = Arrays.asList("dept", "dept1");
// // 忽略表后缀
// List<String> ignoreSuffix = Arrays.asList("dept", "dept1");
return ProcessConfig.builder()
//根据名称指定表生成
// .designatedTableName(Arrays.asList("tb_his_prescription_record_extend", "tb_his_prescription_detail_extend"))
//根据表前缀生成
.designatedTablePrefix(new ArrayList<>())
//根据表后缀生成
.designatedTableSuffix(new ArrayList<>()).build();
//忽略表名
// .ignoreTableName(ignoreTableName)
//忽略表前缀
// .ignoreTablePrefix(ignorePrefix)
//忽略表后缀
// .ignoreTableSuffix(ignoreSuffix).build();
}
}
运行即可生成文档

边栏推荐
- MySQL master-slave multi-source replication (3 master and 1 slave) setup and synchronization test
- Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
- QT tutorial: creating the first QT program
- Command line kills window process
- Advanced learning of MySQL -- basics -- transactions
- Pdf document signature Guide
- Advanced learning of MySQL -- Fundamentals -- concurrency of transactions
- Use source code compilation to install postgresql13.3 database
- Advanced learning of MySQL -- basics -- basic operation of transactions
- js导入excel&导出excel
猜你喜欢

uniapp实现从本地上传头像并显示,同时将头像转化为base64格式存储在mysql数据库中

DAY ONE

Memory optimization of Amazon memorydb for redis and Amazon elasticache for redis

2022 PMP project management examination agile knowledge points (9)

48页数字政府智慧政务一网通办解决方案

GPIO简介

一图看懂对程序员的误解:西方程序员眼中的中国程序员

【vulnhub】presidential1

37 pages Digital Village revitalization intelligent agriculture Comprehensive Planning and Construction Scheme

【vulnhub】presidential1
随机推荐
Leecode brushes questions to record interview questions 17.16 massagist
Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
Leecode brush question record sword finger offer 56 - ii Number of occurrences of numbers in the array II
Leecode brush questions record sword finger offer 44 A digit in a sequence of numbers
Leecode brush questions record sword finger offer 11 Rotate the minimum number of the array
Understand the misunderstanding of programmers: Chinese programmers in the eyes of Western programmers
[CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
Idea automatically imports and deletes package settings
GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
2022 PMP project management examination agile knowledge points (9)
Command line kills window process
C语言输入/输出流和文件操作【二】
Mujoco finite state machine and trajectory tracking
Model-Free Prediction
英雄联盟|王者|穿越火线 bgm AI配乐大赛分享
Oracle EMCC 13.5 environment in docker every minute
Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
Core knowledge of distributed cache
PostgreSQL uses pgpool II to realize read-write separation + load balancing
Advanced learning of MySQL -- basics -- multi table query -- subquery