springcloud+zuul+swagger 分布式接口文檔


https://gitee.com/didispace/swagger-butler

1.引用上面項目中的swagger 工具包

2.zuul 網關配置

zuul.routes.api-apiservice.path=/apiservice/**
zuul.routes.api-apiservice.serviceId=apiservice
zuul.routes.operation-managerment-service.path=/operation-managerment-service/**
zuul.routes.operation-managerment-service.serviceId=operation-managerment-service



#swagger 配置
#通過網關獲取服務地址
swagger.butler.auto-generate-from-zuul-routes=true
#配置需要顯示swagger接口服務的路由名稱
swagger.butler.generate-routes=api-apiservice,operation-managerment-service
swagger.butler.generate-routes 配置需要顯示服務的路由名稱,如果有多個 “,”g隔開
接着zuul啟動類上面添加注解
@SpringBootApplication
@EnableZuulProxy
// 短路監控
@EnableHystrixDashboard
//swagger注解 @EnableSwaggerButler
public class ZuulApplication { public static void main(String[] args) throws Exception { SpringApplication.run(ZuulApplication.class, args); }

網關層配置就完成了,接下來只要在應用服務中引用包就可以了

4.對應的應用服務的pom文件中引用上面的swagger工具包,在啟動類上配置注解

@SpringBootApplication
@EnableDiscoveryClient
@EnableSwaggerButler
public class ApiserviceApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiserviceApplication.class, args);
    }

}

訪問:http://localhost:8082//swagger-ui.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM