springboot2引入swagger3原创
# 1. 引入依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
<version>最新版本</version>
</dependency>
1
2
3
4
5
2
3
4
5
# 2. 填写yml配置文件
dev环境
springdoc:
swagger-ui:
path: /swagger-ui.html
tags-sorter: alpha
operations-sorter: method
api-docs:
path: /v3/api-docs
group-configs:
- group: 'default'
paths-to-match: '/**'
packages-to-scan: com.yupi.springbootinit.controller
# knife4j的增强配置,不需要增强可以不配
knife4j:
enable: true
setting:
language: zh_cn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
prod环境
knife4j:
enable: true
setting:
custom-code: 200
// 生产环境禁用knife4j
production: true
1
2
3
4
5
6
2
3
4
5
6
# 3. 新建配置文件Knife4jConfig
@Configuration
@Profile({"dev", "test"})
public class Knife4jConfig {
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("接口文档")
.version("1.0")
.description("属性:[https://springdoc.org/index.html#properties](https://springdoc.org/index.html#properties),常见问题:[https://springdoc.org/#faq](https://springdoc.org/#faq)")
.termsOfService("https://smartbear.com/terms-of-use/")
.contact(new Contact().name("华总, 邮箱:liyao52033@163.com, 网站:https://wx.zsxq.com/dweb2/index/group/51112524211554"))
);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
上次更新: 2023/12/09 16:19:24
- 01
- element-plus多文件手动上传 原创11-03
- 02
- TrueLicense 创建及安装证书 原创10-25
- 03
- 手动修改迅捷配置 原创09-03
- 04
- 安装 acme.sh 原创08-29
- 05
- zabbix部署 原创08-20