当前位置:网站首页>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界面
边栏推荐
猜你喜欢

监管再次重拳出击,后市如何?2021-05-22

Supervision strikes again, what about the market outlook?2021-05-22

【ONE·Data || Getting Started with Sorting】

Shell脚本完成pxe装机配置

配置zabbix自动发现和自动注册。

科研试剂DSPE-PEG-VIP,二硬脂酰基磷脂酰乙醇胺-聚乙二醇-血管活性肠肽VIP

The world's largest Apache open source foundation is how it works?

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

基于深度学习的图像检索方法!

专访|带着问题去学习,Apache DolphinScheduler 王福政
随机推荐
腾讯安全游戏行业研讨会:生态共建,护航游戏产业健康发展
SQL函数 $TSQL_NEWID
SQL函数 UNIX_TIMESTAMP
els long block deformation conditions, boundary collision judgment
static修饰的函数有什么特点(static可以修饰所有的变量吗)
ping命令的使用及代码_通过命令查看ping路径
CVE-2020-27986 (Sonarqube sensitive information leak) vulnerability fix
动态刷新日志级别
FreeBSD bnxt以太网驱动源码阅读记录三:
世界上最大的开源基金会 Apache 是如何运作的?
A number of embassies and consulates abroad have issued reminders about travel to China, personal and property safety
LayoutParams的详解
C# using 使用方法
拯救流浪猫 | 「喵先锋」系列数字版权盲盒明日开抢
好用的php空间,推荐国内三个优质的免费PHP空间[通俗易懂]
Kunpeng devkit & boostkit
idea社区版下载安装教程_安装天然气管道的流程
此次519暴跌的几点感触 2021-05-21
rhce第三天作业
【Tensorflow】AttributeError: module ‘keras.backend‘ has no attribute ‘tf‘