Building Feign interfaces

An approach where only an interface with some annotations has to be created to provide a component is standard for Spring Framework. For Feign, an interface must be annotated with @FeignClient(name = "..."). It has one required property name, which corresponds to the invoked microservice name if service discovery is enabled. Otherwise, it is used together with the url property, where we can set a concrete network address. @FeignClient is not the only annotation that needs to be used here. Every method in our client interface is associated with a specific HTTP API endpoint by marking it with @RequestMapping or more concrete annotations, such as @GetMapping, @PostMapping, or @PutMapping, as in this example source code ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.