宋子宪博客

Szx

Zuul网关统一管理API Spring Boot启动代码代码
@SpringBootApplication @EnableEurekaClient @EnableZuulPro...
扫描右侧二维码阅读全文
16
2019/08

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

Last modification:August 16th, 2019 at 06:40 pm
如果觉得这篇技术文章对您有帮助,可以请博主喝一杯饮料

Comment here is closed