Spring Cloud Gateway auto routing to Eureka services

两盒软妹~` 提交于 2019-12-11 16:56:13

问题


I work with Spring to create microservices. I am using Eureka for service discovery and Zuul for routing. Now I wanted to switch to Spring Cloud Gateway (because of non-blocking nature) but I've failed to figure out a way of auto routing to each Eureka service.

For example if one service 'eureka-client' registers to Eureka, Zuul does provide a path like localhost:8762/eureka-client to this service by itself. With Spring Cloud Gateway, I've to create a route all by myself for each service.

      routes:
      - id: eureka-client
        uri: lb://eureka-client
        predicates:
        - Path=/eureka-client/**

With a few services that's acceptable but I might get hundreds of services in the end. And each has to write its own route in Spring Cloud Gateway.

Is there a way to provide auto routing from Spring Cloud Gateway to each service from Eureka?


回答1:


The auto routing can be configured.

spring.cloud.gateway.discovery.locator.enabled=true


来源:https://stackoverflow.com/questions/56215050/spring-cloud-gateway-auto-routing-to-eureka-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!