Spring Boot HTTP Clients provides zero-boilerplate auto-configuration for WebClient and Spring 6 HTTP Interface based HTTP clients in a Spring Boot application.
MIT License
Bot releases are visible (Hide)
Full Changelog: https://github.com/maciejwalkowiak/spring-boot-http-clients/compare/v0.1.0...v0.1.1
Published by maciejwalkowiak over 1 year ago
Then, add the dependency to spring-boot-http-clients
:
<dependency>
<groupId>com.maciejwalkowiak.spring</groupId>
<artifactId>spring-boot-http-clients</artifactId>
<version>0.1.0</version>
</dependency>
application.yml
or application.properties
under the prefix http.clients
:http.clients:
todo-client:
url: https://jsonplaceholder.typicode.com/todos
user-client:
url: https://jsonplaceholder.typicode.com/users
The client names (in the above example, todo-client
and user-client
) are just strings - use anything that makes sense - they are going to be used to construct the WebClient
bean name.
The above code gets processed by WebClientsAutoConfiguration
, which creates a bean of type WebClient
with the name <client-name>.WebClient
.
@HttpClient
, and set the client name as the parameter:@HttpClient("todo-client")
public interface TodoClient {
@GetExchange
List<Todo> get();
}
TodoClient
anywhere in your code