3、微服务整合Swagger3.0 - 网关Gateway聚合接口
1、在需要swagger的模块添加依赖
<dependency>
<groupId>com.cch</groupId>
<artifactId>cch-common-swagger</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
2、在启动类添加自定义注解 @EnableCustomSwagger2
@EnableCustomSwagger2
@SpringBootApplication
public class SystemApplication {
public static void main(String[] args) {
SpringApplication.run(SystemApplication.class, args);
}
}
3、在xxxx-dev.yml添加swagger的配置信息
因为其他业务模块已经引入了swagger模块的配置类,所以只需要在yml文件中进行配置即可,或者直接在nacos中进行配置,这样后续也方便维护和修改。
# swagger配置
swagger:
title: "cch-cloud的项目"
description: "接口文档"
version: 3.0.0
license: Powered By cch
licenseUrl: https://xxx.com
4、测试效果
访问http://{ip}:{port}/swagger-ui/index.html
总结:以后哪个模块需要swagger直接引入公共的swagger模块,很方便!