Setup Rest Client in Spring boot 3.2
I could find a lot of tutorials about implementing Feigh Client, WebClient, or even the old library RestTemplate, but a few of RestClient…
Wiki topics:
📚 · Books & Reading
Setup Rest Client in Spring Boot 3.2
I could find a lot of tutorials about implementing Feigh Client, WebClient, or even the old library RestTemplate, but a few of RestClient. Spring boot team advice to migrate RestTemplate to RestClient or WebClient.
- Required dependencies
We don’t need to add any dependency to use RestClient because is part of the spring-webmvc module, it’s included in the web starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- Create a Bean for setting up the Rest client properties
@Configuration
@EnableConfigurationProperties(value = FooProviderApplicationProperties.class)
public class FooApiConfig {
@Bean
FooApiConfigApi fooApiConfigApi() {
RestClient client = RestClient.create("Url");
HttpServiceProxyFactory factory = HttpServiceProxyFactory
.builderFor(RestClientAdapter.create(client))
.build();
return factory.createClient(CredentialAccessApi.class);
}
}
- Declare the Rest third Api contracts using interfaces
@HttpExchange(accept = "application/json", contentType = "application/json")
public interface FooApi{
@PostExchange(contentType = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
ResponseEntity<AzureAuthResponse> getToken(@RequestBody MultiValueMap<String, String> parameters);
@DeleteExchange("/foo")
ResponseEntity<FooResponse> deleteCredentials(@RequestParam("paramx") String paramx,
@RequestParam("paramy") String paramy);
@PostExchange("/boo")
ResponseEntity<BooResponse> save(@RequestBody BooRequest request);
}
- Implement the interfaces
@Slf4j
@Component
public class FooApiAdapter implements FooApiPort {
private final FooApi fooApi;
public FooApiAdapter(FooApi fooApi) {
this.fooApi = fooApi;
}
@Override
public void doSomenthig() {
...
} 메타데이터
- post_id
- 2faef8f22147
- slug
- setup-rest-client-in-spring-boot-3-2-2faef8f22147
- url
- https://medium.com/@vjrojasb/setup-rest-client-in-spring-boot-3-2-2faef8f22147
- canonical_url
- https://medium.com/@vjrojasb/setup-rest-client-in-spring-boot-3-2-2faef8f22147
- author_url
- https://medium.com/@vjrojasb
- status
- ok
- fetched_at
- 2026-07-24 01:50:55