当前位置:网站首页>学习使用代码生成美观的接口文档!!!
学习使用代码生成美观的接口文档!!!
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();
}
}
运行即可生成文档

边栏推荐
- uniapp实现从本地上传头像并显示,同时将头像转化为base64格式存储在mysql数据库中
- Interface master v3.9, API low code development tool, build your interface service platform immediately
- DAY THREE
- Advanced learning of MySQL -- basics -- multi table query -- inner join
- Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
- C语言输入/输出流和文件操作【二】
- stm32F407-------SPI通信
- 智能运维应用之道,告别企业数字化转型危机
- X.509 certificate based on go language
- Supersocket 1.6 creates a simple socket server with message length in the header
猜你喜欢

【vulnhub】presidential1

GPIO简介

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

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

Business process testing based on functional testing

Article management system based on SSM framework

If the college entrance examination goes well, I'm already graying out at the construction site at the moment

How to set encoding in idea

JWT signature does not match locally computed signature. JWT validity cannot be asserted and should

48 page digital government smart government all in one solution
随机推荐
Leecode brushes questions to record interview questions 17.16 massagist
Liuyongxin report | microbiome data analysis and science communication (7:30 p.m.)
Use source code compilation to install postgresql13.3 database
@TableId can‘t more than one in Class: “com.example.CloseContactSearcher.entity.Activity“.
What is AVL tree?
What is a responsive object? How to create a responsive object?
JS import excel & Export Excel
[CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
JWT signature does not match locally computed signature. JWT validity cannot be asserted and should
kubernetes部署ldap
How to use vector_ How to use vector pointer
What can the interactive slide screen demonstration bring to the enterprise exhibition hall
Advanced learning of MySQL -- Fundamentals -- concurrency of transactions
Pdf document signature Guide
C语言输入/输出流和文件操作【二】
专为决策树打造,新加坡国立大学&清华大学联合提出快速安全的联邦学习新系统
TypeScript增量编译
Introduction au GPIO
2022年PMP项目管理考试敏捷知识点(9)
Data analysis course notes (V) common statistical methods, data and spelling, index and composite index