Skip to content

Ensure that there is a RestClient.Builder in the application context #563

Closed
@habuma

Description

@habuma

When Spring AI auto-configures various client implementations, it depends upon a RestClient.Builder to create a RestClient for those client implementations. That works fine when the project uses the Spring MVC starter because a RestClient.Builder will be auto-configured. But when using the Spring WebFlux starter, no such RestClient.Builder is auto-configured and the application will fail to start.

AFAIK, this happens in all recent versions of Spring AI, including 0.8.1 and 1.0.0-SNAPSHOT.

To reproduce, create a simple Spring AI application with a dependency on the WebFlux starter and almost any model starter...such as the OpenAI starter. You do not need to write any code to reproduce this problem. Just create a new Spring Boot project with the aforementioned starters and then try to run it. The application will fail to start and you'll get the following error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 2 of method openAiChatClient in org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration required a bean of type 'org.springframework.web.client.RestClient$Builder' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.web.client.RestClient$Builder' in your configuration.

If Spring AI were to ensure the existence of a RestClient.Builder then the application would start and function fine, even when using WebFlux.

Metadata

Metadata

Assignees

Labels

configurationdocumentationImprovements or additions to documentationduplicateThis issue or pull request already existsenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions