当前位置:网站首页>学习使用代码生成美观的接口文档!!!
学习使用代码生成美观的接口文档!!!
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();
}
}
运行即可生成文档
边栏推荐
- Leecode brushes questions to record interview questions 17.16 massagist
- Use package FY in Oracle_ Recover_ Data. PCK to recover the table of truncate misoperation
- SQL的一种写法,匹配就更新,否则就是插入
- Common shortcuts to idea
- C language input / output stream and file operation [II]
- Rails 4 asset pipeline vendor asset images are not precompiled
- Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
- 陀螺仪的工作原理
- What is a responsive object? How to create a responsive object?
- JWT signature does not match locally computed signature. JWT validity cannot be asserted and should
猜你喜欢
Introduction au GPIO
ldap创建公司组织、人员
【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
智能运维应用之道,告别企业数字化转型危机
Article management system based on SSM framework
Memory optimization of Amazon memorydb for redis and Amazon elasticache for redis
基于GO语言实现的X.509证书
什么是响应式对象?响应式对象的创建过程?
Uniapp uploads and displays avatars locally, and converts avatars into Base64 format and stores them in MySQL database
GPIO簡介
随机推荐
Use source code compilation to install postgresql13.3 database
Use Yum or up2date to install the postgresql13.3 database
Oracle EMCC 13.5 environment in docker every minute
Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
Article management system based on SSM framework
Advanced learning of MySQL -- basics -- multi table query -- subquery
MySQL master-slave multi-source replication (3 master and 1 slave) setup and synchronization test
Operation test of function test basis
Basic information of mujoco
"Latex" Introduction to latex mathematical formula "suggestions collection"
What is web penetration testing_ Infiltration practice
AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06
Typescript incremental compilation
Supersocket 1.6 creates a simple socket server with message length in the header
【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
SQL的一种写法,匹配就更新,否则就是插入
准备好在CI/CD中自动化持续部署了吗?
Cross-entrpy Method
Idea automatically imports and deletes package settings
Quickly use various versions of PostgreSQL database in docker