Affects: Spring framwework 6.1.6
In a sample project, I have put side by side the new RestClient
and the Http interface
(which allows to use annotations such as @GetExchange
)
@Bean
public RestClient restClient() {
return RestClient.create();
}
@Bean
StudentService invoiceServiceWithHttpInterface() {
var restClient = RestClient.builder().baseUrl(endpointUrl).build();
var adapter = RestClientAdapter.create(restClient);
var factory = HttpServiceProxyFactory.builderFor(adapter).build();
return factory.createClient(StudentService.class);
}
Would there be a way to make the HttpInterface
configuration more intuitive? Something like that would be nice:
@Bean
public StudentService invoiceServiceWithHttpInterface() {
return RestHttpInterface.createClient(StudentService.class);
}
Great thanks!
Comment From: snicoll
Please vote for https://github.com/spring-projects/spring-boot/issues/31337 as it would avoid the boilerplate that you're talking about. 3 lines of code doesn't sound too bad to me (straight from the reference guide, so easy to find).
We shouldn't introduce additional high-level concepts in the core framework just so that the above can be written in one line instead of 3.
Comment From: michaelisvy
sure, thanks for your prompt answer! I agree it would be nicer to have an @Enable... annotation. I've subscribed to https://github.com/spring-projects/spring-boot/issues/31337