当前位置:网站首页>学习使用代码生成美观的接口文档!!!
学习使用代码生成美观的接口文档!!!
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();
}
}
运行即可生成文档
边栏推荐
- 【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
- Pdf document signature Guide
- Policy Gradient Methods
- 基于GO语言实现的X.509证书
- The programmer resigned and was sentenced to 10 months for deleting the code. Jingdong came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
- iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
- Geo data mining (III) enrichment analysis of go and KEGG using David database
- Advanced learning of MySQL -- basics -- basic operation of transactions
- C语言输入/输出流和文件操作【二】
- What is a responsive object? How to create a responsive object?
猜你喜欢
陀螺仪的工作原理
沉浸式投影在线下展示中的三大应用特点
After leaving a foreign company, I know what respect and compliance are
2022/2/12 summary
How to set encoding in idea
准备好在CI/CD中自动化持续部署了吗?
MySQL learning notes (mind map)
GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
2022年PMP项目管理考试敏捷知识点(9)
System activity monitor ISTAT menus 6.61 (1185) Chinese repair
随机推荐
Testers, how to prepare test data
Leecode brushes questions to record interview questions 17.16 massagist
什么是响应式对象?响应式对象的创建过程?
Quaternion attitude calculation of madgwick
Compilation of kickstart file
How to use vector_ How to use vector pointer
2022/2/12 summary
Common shortcuts to idea
C language input / output stream and file operation [II]
"Latex" Introduction to latex mathematical formula "suggestions collection"
GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
Random类的那些事
Advanced learning of MySQL -- basics -- multi table query -- joint query
Notes of training courses selected by Massey school
Advanced learning of MySQL -- Fundamentals -- four characteristics of transactions
37 page overall planning and construction plan for digital Village revitalization of smart agriculture
Advanced learning of MySQL -- Fundamentals -- concurrency of transactions
stm32F407-------SPI通信
Advanced learning of MySQL -- basics -- multi table query -- subquery
How engineers treat open source -- the heartfelt words of an old engineer