一、引入依赖
在pom文件引入依赖
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.9.0.RELEASE</version>
</dependency>
复制代码
注:依赖版本可以自己选择
二、添加配置
这里直接在yml配置文件配置设置,无需再另外加配置文件
swagger:
print-init: true
enabled: true
security-configuration:
client-id: client-1
client-secret: secretA
scope-separator: \,
use-basic-authentication-with-access-code-grant: true
dockets:
docket-api:
base-package: 扫描的包的路径
group-name: api
api-info:
title: 要展示的接口名称
description: 接口描述
version:版本号
license: 版权
global-parameters:
- name: token
description: Access Token
param-type: header`
复制代码
三、开启功能
在启动类加注解 @EnableSwagger2Doc 开启,如下所示
近期评论