当前位置:网站首页>Swagger 的使用
Swagger 的使用
2022-08-02 14:01:00 【昊天h1】
Swagger 的使用
1.导入依赖
<!-- 核心包 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<!-- API获取的包 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<!-- 官方UI包 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
2.添加配置类
@Configuration //表明当前类是配置类
@EnableOpenApi //表示开启生成接口文档功能(只有开启了OpenApi,才可以实现生成接口文档的功能)
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo())
.select()
.apis( RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("项目接口文档")//标题
.description("更多请咨询服务开发者c。")//描述
.version("1.0")//版本
.build();
}
}
3.控制层添加注解
| 位置 | 格式 |
|---|---|
| 类 | @Api(tags = “用户信息管理”) |
| 方法 | @ApiOperation(“查询用户”) |
Swagger界面
边栏推荐
- RKMPP API安装使用总结
- 关于市场后市的发展预测? 2021-05-23
- Data Organization---Chapter 6 Diagram---Graph Traversal---Multiple Choice Questions
- 如何解决1045无法登录mysql服务器
- Interviewer: Can you talk about optimistic locking and pessimistic locking?
- web测试和app测试的区别?
- 科研试剂DSPE-PEG-VIP,二硬脂酰基磷脂酰乙醇胺-聚乙二醇-血管活性肠肽VIP
- static修饰的函数有什么特点(static可以修饰所有的变量吗)
- 第二讲 软件生命周期
- RowBounds[通俗易懂]
猜你喜欢

如何解决1045无法登录mysql服务器

面试SQL语句,学会这些就够了!!!

【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘

智能指针-使用、避坑和实现

rhce第三天作业

Mysql's case the when you how to use

乐心湖‘s Blog——MySQL入门到精通 —— 囊括 MySQL 入门 以及 SQL 语句优化 —— 索引原理 —— 性能分析 —— 存储引擎特点以及选择 —— 面试题

logback源码阅读(一)获取ILoggerFactory、Logger

世界上最大的开源基金会 Apache 是如何运作的?

方舟生存进化淘宝面板服务器是怎么一回事?
随机推荐
目标检测场景SSD-Mobilenetv1-FPN
腾讯安全发布Tencent Cloud EdgeOne,为企业出海打造安全加速一体化服务
拯救流浪猫 | 「喵先锋」系列数字版权盲盒明日开抢
vim复制粘贴_vim如何复制粘贴
Detailed explanation of stored procedures
如何自定义feign方法级别的超时时间
【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘
Supervision strikes again, what about the market outlook?2021-05-22
Flutter 实现光影变换的立体旋转效果
腾讯安全游戏行业研讨会:生态共建,护航游戏产业健康发展
FreeBSD bnxt以太网驱动源码阅读记录三:
ORACLE expdp/impdp详解
C language improvement (3)
“多源异构”和“异构同源”定义区分详解「建议收藏」
如何解决1045无法登录mysql服务器
网络安全第二次作业
未来的金融服务永远不会停歇,牛市仍将继续 2021-05-28
鲲鹏devkit & boostkit
Selenium本地打开远程浏览器
About the development forecast of the market outlook?2021-05-23