A small, production‑ready utility module for performing HTTP calls in Spring Boot applications using WebClient.
It is designed to be generic, reusable, and easy to integrate into existing services.
- Generic WebClient service: Centralized component for outbound HTTP calls.
- HTTP method support:
GET,POST,PUT,PATCH, andDELETE. - Simple integration: Drop into any Spring Boot project and wire via dependency injection.
- Exception handling ready: Hooks for central error handling and custom exceptions.
- Add the module to your Spring Boot project (as a dependency or as source).
- Configure
WebClientinWebClientConfigurationaccording to your environment (base URL, timeouts, interceptors, etc.). - Inject
GenericWebClientServiceinto your services or controllers:
@Service
public class ExampleConsumerService {
private final GenericWebClientService genericWebClientService;
public ExampleConsumerService(GenericWebClientService genericWebClientService) {
this.genericWebClientService = genericWebClientService;
}
public Mono<MyResponseDto> callExternalApi() {
return genericWebClientService.get("/uri", MyResponseDto.class);
}
}- Handle errors using the provided
ExternalApiExceptionandGlobalExceptionHandler, or adapt them to your own error model. - Api Base URL is configurable via application.properties
- Language: Java 21
- Framework: Spring Boot 4.0.0
- HTTP client:
spring-boot-starter-webflux(WebClient) - Build tool: Maven