Zuul网关统一管理API Spring Boot启动代码代码
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
@EnableSwagger2Doc
public class AppGateWay {
public static void main(String[] args) {
SpringApplication.run(AppGateWay.class, args);
}
// 添加文档来源
@Component
@Primary
class DocumentationConfig implements SwaggerResourcesProvider {
@Override
public List<SwaggerResource> get() {
List resources = new ArrayList<>();
//会员服务
resources.add(swaggerResource("app-shop-member", "/app-shop-member/v2/api-docs", "2.0"));
//微信服务
resources.add(swaggerResource("app-shop-weixin", "/app-shop-weixin/v2/api-docs", "2.0"));
return resources;
}
private SwaggerResource swaggerResource(String name, String location, String version) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(name);
swaggerResource.setLocation(location);
swaggerResource.setSwaggerVersion(version);
return swaggerResource;
}
}
}
访问方法:ip:端口/v2/api-docs
例如http://localhost:8300/v2/api-docs
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »