代码之家  ›  专栏  ›  技术社区  ›  Serhii

按serviceid的zuul路由不工作

  •  1
  • Serhii  · 技术社区  · 6 年前

    我使用java8,SpringBoot2.0.3,SpringCloud元素基于

    ,请 (尤里卡) .所有服务在启动时加载它们自己的配置 .服务启动时没有问题。

    -在开始时间获取随机端口。这是通过以下方式将zuul rout配置为日历服务的原因: serviceId

    zuul:
      debug:
        request: true
      routes:
        card-service:
            path: /card-service/**
            serviceId: card-service
            stripPrefix: true
    

    使用 我检测到的下一个注册服务的客户端 ["edge-server", "card-service"] card-service bootstrap.yml

    spring:
      application:
        name: card-service
    

    信用卡服务

    http://localhost:59496/card-service/api/cards

    http://localhost:59496/api/cards

    我的祖尔( 开始于 8765

    http://localhost:8765/card-service/api/cards

    得出同样的结果。但结果是空的。检查

    No handler mapping found for [/card-service/api/cards]
    Last-Modified value for [/card-service/api/cards] is: -1
    

    边缘服务器 http://localhost:8765/actuator/mappings

    {
      "contexts": {
        "edge-server-1": {
          "mappings": {
            "dispatcherServlets": {
              "dispatcherServlet": [
                ...,
                {
                  "handler": "org.springframework.cloud.netflix.zuul.web.ZuulController@24a37416",
                  "predicate": "/card-service/**",
                  "details": null
                },
    

    是吗?

    1 回复  |  直到 6 年前
        1
  •  3
  •   Serhii    6 年前

    @EnableZuulServer @EnableZuulProxy 在弹簧保护套配置中。 需要加载配置的 routes