Swagger
Swagger3是接口文档生成工具
依赖 pom.xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
配置文件 application.yml
server:
port: 8080
servlet:
context-path: /api # 如果填写接口文档地址则为api/doc.html
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/library-management?serverTimezone=GMT%2b8
username: root
password: 123456
# 支持 swagger3
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# 接口文档配置
knife4j:
enable: true
openapi:
title: "接口文档"
version: 1.0
group:
default:
api-rule: package
api-rule-resources:
- com.example.springboot.controller # 写自己的包
然后我们启动项目
http://localhost:8080/api/doc.html#/home (我的接口文档地址)
打开后就能看到接口文档页面
http://localhost:8080/api/v2/api-docs (这里可以看到Swagger源码)
标签:接口,api,文档,Swagger,com,localhost From: https://www.cnblogs.com/HanXuxian/p/18059723