首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring cloud Zuul url配置

问Spring cloud Zuul url配置
EN

Stack Overflow用户
提问于 2019-04-25 12:35:24
回答 1查看 617关注 0票数 0

我正在尝试使用zuul和Eureka服务器运行一个示例。

下面是我的配置:

代码语言:javascript
复制
eureka-service 

server.port=8761

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

logging.level.com.netflix.eureka=OFF
logging.level.com.netflix.discovery=OFF

eureka -client (bootstrap.properties):

spring.application.name=ab
management.server.port=9001
management.server.address: 127.0.0.1
server.port=8081

edge-service(zuul) :

zuul.routes.ab.url=http://localhost:8081
ribbon.eureka.enabled=false
spring.application.name=API-Gateway
eureka.client.eureka-server-port=8761
server.port=8080

当我点击URL http:localhost:8080/clientapi时,我得到了一个白色标签错误页面,似乎缺少什么配置,因为我可以看到边缘服务以及eureka-client,都正确地注册到了eureka -server。

我使用的是spring boot: 2.1.4。

EN

回答 1

Stack Overflow用户

发布于 2019-08-13 19:50:45

让我给你看我的例子:

application.yml文件中的尤里卡:

代码语言:javascript
复制
server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: true
    instance-info-replication-interval-seconds: 10
  server:
    eviction-interval-timer-in-ms: 50000
    wait-time-in-ms-when-sync-empty: 5

zuul:

代码语言:javascript
复制
zuul.routes.1.url=http://localhost:8081
zuul.routes.2.url=http://localhost:8082

zuul.prefix=/client

zuul.host.max-per-route-connections=10
zuul.host.max-total-connections=10

我有两个服务(1 -本地主机:8081和2-本地主机:8082)

你需要注释主类Zuul:

代码语言:javascript
复制
@EnableZuulProxy
@EnableDiscoveryClient

然后启动应用程序。当您转到

代码语言:javascript
复制
localhost/8070/client/1

时,将重定向到第一个服务(localhost:8081)。

代码语言:javascript
复制
localhost/8070/client/2

我希望它能对你有所帮助。

您将重定向到第二个服务(localhost:8082)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55841843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档