簡體   English   中英

Spring Cloud ZUUL在yml中配置?

[英]Spring cloud ZUUL Configuration in yml?

我想在application.yml文件中配置ZUUL屬性,但是以某種方式我無法在yml文件中定義路由(我在瀏覽器中找不到頁面)。 但是,它在application.properties文件中完美運行 以下是application.propertiesapplication.yml文件中的屬性。

application.properties

#subway is the application context name of a microservice. This works perfectly fine.
zuul.routes.**subway**.url=http://localhost:7777/

applcation.yml文件

zuul:
  routes:
    subway:
      path: /subway/**
      url: http://localhost:7777/

也嘗試過:

zuul:
  routes:
      service-id: /subway/**
      path: /subway/**
      url: "http://localhost:7777/"
      strip-prefix: false
      service-id: /subway1/**
      path: /subway1/**
      strip-prefix: false
      url: "http://localhost:6666/"
      service-id: /subway2/**
      path: /subway2/**
      url: "http://localhost:5555/"
      strip-prefix: false

我有例外

由以下原因引起:org.yaml.snakeyaml.parser.ParserException:在“讀取器”的第12行第7列中解析MappingNode時:service-id:/ subway / **

我有什么想念的嗎?

以下是其工作方式。 謝謝@harshavmb和@pvpkiran:

zuul:
  routes:
    subway:
      service-id: /subway/**
      path: /subway/**
      url: "http://localhost:7777/"
      strip-prefix: false
    subway1:
      service-id: /subway1/**
      path: /subway1/**
      strip-prefix: false
      url: "http://localhost:6666/"
    subway2:
      service-id: /subway2/**
      path: /subway2/**
      url: "http://localhost:5555/"
      strip-prefix: false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM