spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Dependency on spring-boot-starter-web should be transitive or specified

Open jottinger opened this issue 1 year ago • 4 comments
trafficstars

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.

jottinger avatar Mar 30 '24 11:03 jottinger

i had same issues,and if i remove 'spring-ai-openai-spring-boot-starter',the program was able to start

pumpkiiinnn avatar Apr 07 '24 03:04 pumpkiiinnn

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

pumpkiiinnn avatar Apr 07 '24 04:04 pumpkiiinnn

i have the same issue when i import spring reactive web instead of spring boot starter web

innovationmech avatar Apr 29 '24 08:04 innovationmech

Me too

shouge avatar May 15 '24 02:05 shouge

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

yueyangbo123 avatar Jun 29 '24 02:06 yueyangbo123

Thanks for reporting, we will aim to fix this for M2

markpollack avatar Jul 22 '24 19:07 markpollack

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.

A-Joshi avatar Aug 12 '24 20:08 A-Joshi