title: How can I get the Discovery Client working when using spring-cloud together with netflix Eureka?
body: <p>I'm trying to make a basic project using spring cloud with the netflix addons such as Hystrix, Eureka and Ribbon to learn how this works. The project I'm trying to make is a simple message server that will keep messages. And a message-client that will just ask the server for a message, and I want to use the auto discovery client for this, or the RestTemplate discovery. But I can't get either to work.  </p>
  
  <p>I have the following structure:</p>
  
  <ul>
  <li>message-client (eureka client)</li>
  <li>message-server (eureka client)</li>
  <li>configuration-service (config server)</li>
  <li>discovery-service (eureka server)</li>
  </ul>
  
  <p>What I currently do is I start up the configuration-service, and expose the application.yml details to all of these "apps/clients" when they are connecting by the following structure:</p>
  
  <ul>
  <li>config-service\src\main\resources\config\appname.yml</li>
  <li>app\src\main\resources\bootstrap.yml (contains the appname and url to cloud config)</li>
  </ul>
  
  <p>This is working just fine, and my apps start up on the port they receive from the config server, as well as they all connect to my eureka server, and all of them are visible there. As well as the Hystrix failover is also working, not that it is related to this but it tells me that it can't be completely wrong then. </p>
  
  <p>But here comes my confusion... 
  When using the @Autowired annotation in my service class (@Service annotated) inside my client module, I get a discoveryClient object, but I am unable to find any other services using that one.</p>
  
  <p>Message Client - boot class: </p>
  
  <pre><code>@EnableAutoConfiguration
  @EnableHystrix
  @EnableEurekaClient
  @ComponentScan("cloud.rest.resources, spring.cloud.client")
  public class ClientBoot {
      public static void main(String[] args) {
          SpringApplication.run(ClientBoot.class, args);
      }
  }
  </code></pre>
  
  <p>Message Client - REST Resource:</p>
  
  <pre><code>@RestController
  public class MessageResource {
      @Autowired
      private MessageClient messageClient;
      @RequestMapping(value = "/message/{client}", method = RequestMethod.GET)
      public Message getMessage(@PathVariable String client) {
          return messageClient.getMessage(client);
      }
  }
  </code></pre>
  
  <p>Message Client - MessageClient:</p>
  
  <pre><code>@Service
  public class RestMessageClient implements MessageClient {
      @Autowired
      private DiscoveryClient discoveryClient;
      @Autowired
      private RestTemplate restTemplate;
      @Override
      public Message getMessage(String client) {
          return restTemplate.getForObject(String.format("http://message-server/message/%s", client), Message.class);
      }
  }
  </code></pre>
  
  <p>My message server boot class that is holding the messages has the same annotations as my client one.</p>
  
  <p>And as I said, my service class are unable to find anything..
  Which leads me to all of my questions:</p>
  
  <ol>
  <li>What is required to actually use ribbon load balancer?</li>
  <li>Do I have to use ribbon to be able to use the "auto discovery", I thought not but now I'm just confused.</li>
  <li>From what I've understood, when using EnableEurekaClient I should not need to use the EnableDiscoveryClient as well?</li>
  <li>Can I change the yml files on my config-server for the clients in runtime and just have to reboot the client?</li>
  <li>How much configuration is really meant to be shared by the config-server, because currently all of my clients just contain a super basic bootstrap.yml file.</li>
  <li>Does anyone have a good link to where I can read more about all the properties that is being set in my yml files? Both a documentation of what the properties that exists actually do as well as some documentation on how I can use them in combination with spring cloud?</li>
  <li>Do I need specific properties to enable my apps/clients to find other apps/clients?</li>
  </ol>
  
  <p><strong>Edited information</strong></p>
  
  <p>Thank you for your quick and excellent reply, I've gone through this over and over today and I finally got my application working..
  The problem (I can't understand why and was hoping you could help me understand that) is that my discovery service contains yml files for each of my other clients where I specify things like port and eureka information.. What I specified here as well was:</p>
  
  <pre><code>eureka:
      client:
          serviceUrl:
              defaultZone: http://localhost:8761/eureka
  </code></pre>
  
  <p>So, when I set this value it seems to override something that makes my service discovery not working.. Even tho I can see all my applications in the eureka server, they were unable to find each other when I had this value set.</p>
  
  <p>I set this value by having a message-server.yml file in my configuration service that is sent out to my message-server application after bootstrap..</p>
  
  <p>So then I have two new questions.</p>
  
  <ol>
  <li>How do I override this eureka server property?</li>
  <li>Why does my discovery client stop working when I set this value, what is it that it actually does?</li>
  </ol>