【问题标题】:What if there are 'N' numbers of microservices then do we have to configure them all manually in Zuul Api Gateway?如果有“N”个微服务,我们是否必须在 Zuul Api Gateway 中手动配置它们?
【发布时间】:2021-01-14 21:48:19
【问题描述】:

假设我们有zuul api gateway,并且没有微服务公司,那么我们如何路由到所有微服务?我们是否必须在api网关的属性文件中手动编写它们的配置?

`例如

zuul:
 prefix: /api  
    routes:  
     defects-service:  
      path: /defects-service/**  
       serviceId: defects-service`  

我们是否必须在 application.properties 文件中为所有微服务编写此内容?

【问题讨论】:

    标签: spring-boot microservices spring-cloud netflix-zuul api-gateway


    【解决方案1】:

    如果你使用Eureka (Discovery service) 和 Zuul,你不需要手动给出 Zuul 中的所有路由。相反,Zuul 会扫描 eureka 注册表并获取所有已注册的应用程序

    并确保您在 zuul 服务器中设置了这两个属性

    eureka.client.registerWithEureka=true
    eureka.client.fetchRegistry=true
    

    【讨论】:

    • 好的,通过 URL 我们可以调用我们想要的在 eureka 中注册的任何微服务,对吧? API网关运行的端口的第一个地址然后/控制器中提到的服务/路径的名称
    猜你喜欢
    • 2012-09-14
    • 2018-11-11
    • 1970-01-01
    • 2019-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 2021-11-30
    相关资源
    最近更新 更多