<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.1</li>
<li>Operating System version: windows10</li>
<li>Java version: java8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">I run the <a href="https://github.com/dubbo-x/example/tree/master/java-dubbo-consul2">code</a> by follow steps:</p>
<ul dir="auto">
<li>docker run -p 8400:8400 -p 8500:8500 -p 8600:8600 -d consul</li>
<li>run provider</li>
<li>run consumer</li>
</ul>
<h3 dir="auto">Actual Result</h3>
<ul dir="auto">
<li>provider runs ok</li>
<li>consumer fail with <code class="notranslate">no provider available</code></li>
</ul>
<p dir="auto">So I trace the register and subscribe process:</p>
<ul dir="auto">
<li>provider register result show below</li>
</ul>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16648345/59485088-f48b5c80-8ea6-11e9-9be1-63a02472150d.png"><img src="https://user-images.githubusercontent.com/16648345/59485088-f48b5c80-8ea6-11e9-9be1-63a02472150d.png" alt="register" style="max-width: 100%;"></a></p>
<p dir="auto">and we can see it use <code class="notranslate">url.getServiceInterface()</code> as service name (this example is <code class="notranslate">dubbo.DubboService</code>)</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/apache/dubbo/blob/6f3a05ca820dc6e3dab127cd9a5daa375709347a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java#L255-L265">dubbo/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 255 to 265
      in
      <a data-pjax="true" class="commit-tease-sha" href="/apache/dubbo/commit/6f3a05ca820dc6e3dab127cd9a5daa375709347a">6f3a05c</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L255" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="255"></td>
          <td id="LC255" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">private</span> <span class="pl-smi">NewService</span> <span class="pl-en">buildService</span>(<span class="pl-smi">URL</span> <span class="pl-s1">url</span>) { </td>
        </tr>

        <tr class="border-0">
          <td id="L256" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="256"></td>
          <td id="LC256" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-smi">NewService</span> <span class="pl-s1">service</span> = <span class="pl-k">new</span> <span class="pl-smi">NewService</span>(); </td>
        </tr>

        <tr class="border-0">
          <td id="L257" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="257"></td>
          <td id="LC257" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setAddress</span>(<span class="pl-s1">url</span>.<span class="pl-en">getHost</span>()); </td>
        </tr>

        <tr class="border-0">
          <td id="L258" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="258"></td>
          <td id="LC258" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setPort</span>(<span class="pl-s1">url</span>.<span class="pl-en">getPort</span>()); </td>
        </tr>

        <tr class="border-0">
          <td id="L259" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="259"></td>
          <td id="LC259" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setId</span>(<span class="pl-en">buildId</span>(<span class="pl-s1">url</span>)); </td>
        </tr>

        <tr class="border-0">
          <td id="L260" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="260"></td>
          <td id="LC260" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setName</span>(<span class="pl-s1">url</span>.<span class="pl-en">getServiceInterface</span>()); </td>
        </tr>

        <tr class="border-0">
          <td id="L261" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="261"></td>
          <td id="LC261" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setCheck</span>(<span class="pl-en">buildCheck</span>(<span class="pl-s1">url</span>)); </td>
        </tr>

        <tr class="border-0">
          <td id="L262" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="262"></td>
          <td id="LC262" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setTags</span>(<span class="pl-en">buildTags</span>(<span class="pl-s1">url</span>)); </td>
        </tr>

        <tr class="border-0">
          <td id="L263" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="263"></td>
          <td id="LC263" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">service</span>.<span class="pl-en">setMeta</span>(<span class="pl-smi">Collections</span>.<span class="pl-en">singletonMap</span>(<span class="pl-c1">URL_META_KEY</span>, <span class="pl-s1">url</span>.<span class="pl-en">toFullString</span>())); </td>
        </tr>

        <tr class="border-0">
          <td id="L264" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="264"></td>
          <td id="LC264" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">return</span> <span class="pl-s1">service</span>; </td>
        </tr>

        <tr class="border-0">
          <td id="L265" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="265"></td>
          <td id="LC265" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> } </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<ul dir="auto">
<li>however if we add group and version info, consumer will use <code class="notranslate">url.getServiceKey()</code> to find service (this example is <code class="notranslate">dubbo-x/dubbo.DubboService:0.0.1</code>), which doesn't equal the service name</li>
</ul>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/apache/dubbo/blob/6f3a05ca820dc6e3dab127cd9a5daa375709347a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java#L141-L144">dubbo/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 141 to 144
      in
      <a data-pjax="true" class="commit-tease-sha" href="/apache/dubbo/commit/6f3a05ca820dc6e3dab127cd9a5daa375709347a">6f3a05c</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L141" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="141"></td>
          <td id="LC141" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-smi">String</span> <span class="pl-s1">service</span> = <span class="pl-s1">url</span>.<span class="pl-en">getServiceKey</span>(); </td>
        </tr>

        <tr class="border-0">
          <td id="L142" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="142"></td>
          <td id="LC142" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-smi">Response</span>&lt;<span class="pl-smi">List</span>&lt;<span class="pl-smi">HealthService</span>&gt;&gt; <span class="pl-s1">response</span> = <span class="pl-en">getHealthServices</span>(<span class="pl-s1">service</span>, -<span class="pl-c1">1</span>, <span class="pl-en">buildWatchTimeout</span>(<span class="pl-s1">url</span>)); </td>
        </tr>

        <tr class="border-0">
          <td id="L143" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="143"></td>
          <td id="LC143" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">index</span> = <span class="pl-s1">response</span>.<span class="pl-en">getConsulIndex</span>(); </td>
        </tr>

        <tr class="border-0">
          <td id="L144" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="144"></td>
          <td id="LC144" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">urls</span> = <span class="pl-en">convert</span>(<span class="pl-s1">response</span>.<span class="pl-en">getValue</span>()); </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">So consumer will not find the service if we add group and version info. Is my configuration wrong?</p>
<p dir="auto">Replace existing hard coded values for dubbo-config below classes</p>
<ul dir="auto">
<li>dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java</li>
<li>dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java</li>
<li>dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java</li>
<li>dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java</li>
<li>dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java</li>
<li>dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConsumerConfig.java</li>
</ul>
<p dir="auto">Along with hard coded value replacement have done small refactoring to use java stream and lambda.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: xxx</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>xxx</li>
<li>xxx</li>
<li>xxx</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>