spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.32k stars 40.71k forks source link

Introduce a starter for HTTP Client applications #42715

Open ThomasVitale opened 1 month ago

ThomasVitale commented 1 month ago

I'd like to suggest introducing a new Spring Boot starter aimed at client applications, with the necessary dependencies and autoconfiguration (e.g. RestClientAutoConfiguration) for HTTP and for related slice tests. Perhaps, two starters for imperative and reactive scenarios: spring-boot-http-client-starter and spring-boot-http-client-reactive-starter, or something like that.

In the past few years, building CLI applications with Java has become more and more common, also thanks to projects like GraalVM and Spring Shell. Reducing the friction for bootstrapping a CLI project that needs HTTP interactions would greatly help increase the adoption of the Spring stack for this purpose.

Most recently, Spring AI brought new use cases for CLI applications, which would need an HTTP client infrastructure without the burden of an entire web server stack.

Besides the CLI use case, introducing such a starter would help imperative applications that need a WebClient (required by Spring AI for streaming scenarios, because RestClient doesn't support streaming) include just client dependencies instead of the entire server stack.

Whether it is possible to set the spring.main.web-application-type=none property for disabling the web server part of the autoconfigured stack, the developer experience could be improved. Also, including several additional server dependencies which are not used is not ideal, especially from a maintenance and supply chain management point of view.

It would be great to be able to bootstrap a client-only application from Spring Initializr. I'm available to help with the implementation, if you think this is something that makes sense for the project.

Related issues on Spring Boot:

Related issues on Spring AI:

Related issues on Spring Pet Clinic:

wilkinsona commented 1 month ago

Thanks for the suggestion. As things stand, we can't differentiate between a dependency on spring-webflux that's intended to provide a reactive HTTP client and a dependency on spring-webflux that's intended to provide a reactive web server. As such, this is largely a duplicate of #12973 and/or #37599. We can leave this issue open to consider providing a starter or two for HTTP client applications, but it's blocked until one or both of those issues has been tackled.

ThomasVitale commented 1 month ago

Ok, thanks for the quick and detailed answer.