0

我正在使用 spring cloud consul 注册我的服务,但它总是会替换 . to - 在注册之前,像这样:

我的应用程序名称:com.test.app

领事中的名字:com-test-app

我试过spring.application.name& spring.cloud.consul.discovery.service-name,它们是一样的。

有谁知道如何避免这种转换?

非常感谢。

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

2017 年 6 月 23 日更新:

我试过用curl注册consul,它支持这个,所以我猜是转换是spring cloud的限制,请帮忙!

    pansion@server ~ -> 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
    pansion@server ~ ->
    pansion@server ~ -> 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": []
    }

    pansion@server ~ ->
    pansion@server ~ -> 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
        }
    ]

    pansion@server ~ ->
4

1 回答 1

1

从技术上讲,服务名称不应包含点或句点,请参阅文档

符合 DNS 的服务和标签名称可能包含任何字母数字字符以及破折号。不支持点,因为 Consul 在内部使用它们来分隔服务标签。

于 2017-06-20T16:37:11.703 回答