This is a follow-up issue to (https://github.com/spring-projects/spring-boot/issues/9690)
I want to use a Flux WebClient in a reuse-library. This library is a web-client only and should not include any http-server component. My library is to be used in console / shell applications, which also have no use for any http-server component. I know that It is possible to configure the http-client. But it seems, you can not have the http-client without the server. If I take out the dependency to the webflux-starter, and work with the spring-webflux dependency only, I get the error message:
Web application could not be started as there was no org.springframework.boot.web.reactive.server.ReactiveWebServerFactory bean defined in the context.
````
I know that I could use the whole webflux-starter dependency and disable the start of the server, for example in a console application. But this still gets me a lot of things in my archive, that are not needed. And, additionally, if I add the webflux-starter in a reuse-library, I have to advise all consumers of my library to take care about the required server. Not nice.
I would expect that If there is no http-server in the classpath, the autoconfiguration considers this correctly and does not try to configure any component that might need the server.
For an example see: (https://github.com/gfinger/arcadeclient). The latest commit uses the webflux-starter in the reuse-library, and starts the console disabling the start of the server. If you run
mvn install && mvn spring-boot:run -pl console -DskipTests ```
from the parent directory you will see a shell prompt. The console runs sucessfully.
If you checkout the commit with tag "no-server-error" and run the same maven command, you'll get the error above saying that there is no ReactiveWebServerFactory.
I don't need the WebServer, only the Flux WebClient. What can I do?
Comment From: wilkinsona
You can configure the web application type as described here and here in the documentation.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
Comment From: wilkinsona
Sorry, looking more closely at the sample, I see now that you already know about web application type. That's the correct approach here. You could provide an environment post-processor in your library that adds a low precedence property source that sets the web application type to none. This would then avoid the need for every user of the library to configure it themselves.
The current behavior is an unfortunate side-effect of Spring Framework packaging both client and server code in its spring-webflux module. This isn't a problem in the servlet stack as spring-webmvc only contains server code with RestTemplate being part of spring-web. https://github.com/spring-projects/spring-boot/issues/12973 is tracking some improvements in this area and, if I now understand this issue correctly, I believe it duplicates #12973.