Given the following code sample
-- client library code
@FeignClient("string-service")
public interface StringClient {
@RequestMapping(method = RequestMethod.GET, value = "/microservicestring")
public String home();
}
@Service
public class StringHystrixClient {
private final SpringClient springClient;
//....
}
-- service library code
@RestController
public class StringController implements StringClient {
public String home(){
return "World";
}
}
@SpringBootApplication
@EnableHystrix
@EnableEurekaClient
@EnableFeignClients
public class StringApplication { ....}
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.
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?