spring-ai
spring-ai copied to clipboard
Dependency on spring-boot-starter-web should be transitive or specified
I created a new Spring AI project using the Spring Initializr, including spring-shell-starter and spring-ai-openai-spring-boot-starter. After adding an OpenAI key, I get a failure on running a simple test that injects a ChatClient:
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.
And if I run the application (ignoring the tests):
Web application could not be started as there was no org.springframework.boot.web.reactive.server.ReactiveWebServerFactory
This is trivially repaired by adding a dependency on spring-boot-starter-web (and certainly has other solutions, too, because you don't HAVE to use the starter to get these classes) but it's not clearly indicated in the Spring AI documentation, and I'd expect the Initializr project to include those dependencies itself as well.
i had same issues,and if i remove 'spring-ai-openai-spring-boot-starter',the program was able to start
i had same issues,and if i remove 'spring-ai-openai-spring-boot-starter',the program was able to start
i found the problem,need add 'spring-boot-starter-web' in you maven
i have the same issue when i import spring reactive web instead of spring boot starter web
Me too
If you have configured "web-application-type", you can try to remove it and restart from
server:
port: 8091
spring:
application:
name: Spring-ai-demo
main:
web-application-type: reactive
to
server:
port: 8091
spring:
application:
name: Spring-ai-demo
Thanks for reporting, we will aim to fix this for M2
I was wondering why I need spring-boot-starter-web if I am not building a web applicaiton but only building a commandline application? I don't believe OpenAI (or the other frameworks) need anything other than a REST API client? At least I did not need one when building openai apps using Python.