自定义指定微服务的访问路径
一 介绍配置zuul.routes.指定微服务的serviceid=指定路径。例如:zuul: routes: users: /myusers/**二 实战1 修改配置如下:server:port: 8040spring:application:name: microservice-gateway-zuuleureka:client:service...
·
一 介绍
配置zuul.routes.指定微服务的serviceid=指定路径。例如:
zuul:
routes:
users: /myusers/**
二 实战
1 修改配置如下:
server:
port: 8040
spring:
application:
name: microservice-gateway-zuul
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
prefer-ip-address: true
zuul:
routes:
microservice-provider-user: /user/**
2 地址栏输入
http://localhost:8040/user/1
3 地址栏输入
http://localhost:8001/1
可以获得同样的结果
4 说明
当输入
http://localhost:8040/user/1,由配置microservice-provider-user: /user/**可知,会路由到microservice-provider-user微服务,microservice-provider-user微服务对应的URL为
http://localhost:8001
更多推荐
已为社区贡献25条内容
所有评论(0)