Zuul:zuul.routes.shop.url的映射不起作用

时间:2019-03-16 01:42:49

标签: java routing microservices netflix-eureka netflix-zuul

我有2个微服务: ArticleMicroService ShopMicroService 。我使用Zuul作为API网关。它们已连接到EurekaServer。

我想将ArticleMicroService中的数据映射到ZuulService,后者将它们映射到ShopMicroService的端口。这意味着数据来自文章-> Zuul / Eureka->商店

问题是,带有“ zuul.routes.shopmicroservice.url = http://localhost:8080”的映射不起作用。 配置如下:

ArticleMicroService属性:

server.port=8084
spring.application.name=articlemicroservice

eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/
eureka.client.fetchRegristry=true
eureka.instance.preferIpAddress=true

spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:shop

eureka.client.instance.lleaseRenewalIntervalInSeconds=1
eureka.client.instance.leaseExpirationDurationInSeconds: 2
ribbon.eureka.enabled=true

ShopMicroService属性:

server.port=8080
spring.application.name=shopmicroservice

eureka.instance.hostname=localhost
eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/
eureka.instance.preferIpAddress=true

spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:shop

ZuulService属性:

server.port=8079
spring.application.name=zuulservice

eureka.instance.preferIpAddress=true
eureka.client.fetchRegristry=true
eureka.client.serviceUrl.defaultZone=http://localhost:8888/eureka/

management.security.enabled=false

zuul.routes.articlemicroservice.url=http://localhost:8080
zuul.prefix=/shop
zuul.routes.articlemicroservice.path=/**
zuul.routes.articlemicroservice.serviceId=articlemicroservice

总结一下,我想通过以下方式获取文章数据:

http://localhost:8080/shop/articles

编辑:我尝试了各种方法来配置zuul.routes.url,并且一次都无法运行

0 个答案:

没有答案