Skip to content

How can I get a WebClient without a required dependency to any web server? #34198

Closed as not planned
@gfinger

Description

@gfinger

This is a follow-up issue to (#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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions