title: How to safely have a @RestController class implementing an interface annotated with @FeignClient
body: <p>Given the following code sample </p>
  
  <p>-- client library code</p>
  
  <pre><code>@FeignClient("string-service")
  public interface StringClient {
  
       @RequestMapping(method = RequestMethod.GET, value = "/microservicestring")
        public String home();
  }
  
  
  @Service
  public class StringHystrixClient {
  
      private final SpringClient springClient;
  //....
  
  }
  </code></pre>
  
  <p>-- service library code</p>
  
  <pre><code>@RestController
  public class StringController implements StringClient {
      public String home(){
           return "World";
      }
  }
  
  
  @SpringBootApplication
  @EnableHystrix
  @EnableEurekaClient
  @EnableFeignClients
  public class StringApplication { ....}
  </code></pre>
  
  <p>If the service library references the client library, when the application gets started, through component scanning we will get to a state where in filling the dependencies from StringHystrixClient, the spring container will not know what to do because there are two beans implementing StringClient.</p>
  
  <p>One solution to avoid this would be to not implement the StringClient in the StringController, but the code duplication from the interface and the rest controller would be error prone. Can somebody point out a more elegant solution to this problem?</p>