spring cloud - How to safely have a @RestController class implementing an interface annotated with @FeignClient -
given 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 service library references client library, when application gets started, through component scanning state in filling dependencies stringhystrixclient, spring container not know because there 2 beans implementing stringclient.
one solution avoid not implement stringclient in stringcontroller, code duplication interface , rest controller error prone. can point out more elegant solution problem?
Comments
Post a Comment