Calling a remote REST endpoint does not require writing the HTTP-calling code yourself. An OpenFeign client is an annotated Java interface: its methods describe endpoint calls, and OpenFeign supplies their implementation. section 11.3
To define a client:
- Annotate the interface with @FeignClient, giving it a unique name and a base URI. Keep environment-specific URIs in properties, rather than hardcoding them. section 11.3
- Declare a method for each endpoint call and use annotations to specify its path, HTTP method, and any request parameters, headers, or body. section 11.3
- Enable client discovery with @EnableFeignClients. Spring provides the generated client as a bean that application components can inject. section 11.3
A payments client
A PaymentsProxy interface can use @FeignClient(name = "payments", url = "${name.service.url}") and declare createPayment with @PostMapping("/payment"), a request header, and a request body. OpenFeign implements the call; a controller can inject and use the proxy. section 11.3
Figure 11.5 With OpenFeign, you only need to define an interface (a contract) and tell OpenFeign where to find this contract to implement it. OpenFeign implements the interface and provides the implementation as a bean in the Spring context based on configurations you define with annotations. You can inject the bean from the Spring context anywhere you need it in your app.

The diagram traces the contract-to-bean flow: define the interface, let OpenFeign implement it, then inject the bean where needed. section 11.3
