2017-06-19 61 views
0

我正在使用spring雲領事來註冊我的服務,但它會一直替代我的服務。到 - 註冊,這樣才:春雲領事將取代。到 - 在註冊之前

我的應用程序名稱:com.test.app

名稱中領事:com-test-app

我試過spring.application.name & spring.cloud.consul.discovery.service-name,它們是相同的。

任何人都知道如何避免這種轉換?

非常感謝。

=======================================

更新於君23,2017:

我試着用curl向領事註冊,它支持這個,所以我猜這是轉換是春天的雲限制,請大家幫忙!

[email protected] ~ -> curl -XPUT 127.0.0.1:8500/v1/agent/service/register -d '{ "ID": "test_001", "Name":"com.test.app", "Address": "10.0.0.10", "Port": 8080 }' 
     % Total % Received % Xferd Average Speed Time Time  Time Current 
            Dload Upload Total Spent Left Speed 
    100 81 0  0 100 81  0  81 0:00:01 --:--:-- 0:00:01 81000 
    [email protected] ~ -> 
    [email protected] ~ -> curl 127.0.0.1:8500/v1/catalog/services 
     % Total % Received % Xferd Average Speed Time Time  Time Current 
            Dload Upload Total Spent Left Speed 
    100 45 100 45 0  0  45  0 0:00:01 --:--:-- 0:00:01 45000{ 
     "com.test.app": [], 
     "consul": [] 
    } 

    [email protected] ~ -> 
    [email protected] ~ -> curl 127.0.0.1:8500/v1/catalog/service/com.test.app 
     % Total % Received % Xferd Average Speed Time Time  Time Current 
            Dload Upload Total Spent Left Speed 
    100 551 100 551 0  0 36733  0 --:--:-- --:--:-- --:--:-- 36733[ 
     { 
      "ID": "3789117d-a44e-c82b-07dd-b386a1f2eeef", 
      "Node": "server", 
      "Address": "127.0.0.1", 
      "Datacenter": "dc1", 
      "TaggedAddresses": { 
       "lan": "127.0.0.1", 
       "wan": "127.0.0.1" 
      }, 
      "NodeMeta": {}, 
      "ServiceID": "test_001", 
      "ServiceName": "com.test.app", 
      "ServiceTags": [], 
      "ServiceAddress": "10.0.0.10", 
      "ServicePort": 8080, 
      "ServiceEnableTagOverride": false, 
      "CreateIndex": 12, 
      "ModifyIndex": 12 
     } 
    ] 

    [email protected] ~ -> 

回答

0

技術上的服務名稱不應包含點或時間段,請參考documentation

兼容的DNS服務和標籤名稱可以包含任何字母數字字符,以及破折號。不支持點,因爲Consul在內部使用它們來分隔服務標籤。

+0

謝謝您的回覆。 但consul rest API可以支持,例如,這可以工作: curl -XPUT 127.0.0.1:8500/v1/agent/service/register -d'{「ID」:「test_001」,「Name」:「 com.test.app「,」Address「:」10.0.0.10「,」Port「:8080}' – Pansion

+0

這是PUT,你在GET中得到的迴應是什麼?它會內部轉換該DOT – VelNaga

+0

謝謝,更新了原始帖子中的curl響應。 – Pansion