io.swagger swagger-annotations 1.5.20 provided com.github.xiaoymin knife4j-spring-boot-starter 2.0.9
SpringBoot的其他配置就省略了,自行查阅。启动项目即可,访问http://localhost/doc.html,如下图
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/1e3f720a285646f18d6ec948ecf8341e.png#pic_center)
### 微服务聚合API文档
在微服务环境下,我们每个服务都有各自的API文档,这样访问起来非常麻烦,那么此时我们就需要使用聚合API文档了。knife4j也具备聚合文档的能力,我们需要创建一个独立的SpringBoot聚合服务,然后添加一下maven依赖:
com.github.xiaoymin knife4j-aggregation-spring-boot-starter 2.0.8
微服务聚合模式分为Disk、Cloud、Eureka、Nacos四种模式,我这里先以Cloud模式为例。
配置yml
knife4j配置
knife4j:
开启聚合
enableAggregation: true
Cloud模式
cloud:
# 开启
enable: true
# 路由配置
routes:
- name: easypoi测试
uri: localhost:8001
location: /v2/api-docs?group=WEB接口文档1.0版本
- nam