spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/index.html
Apache License 2.0
2.63k stars 640 forks source link

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

Open jottinger opened 3 months ago

jottinger commented 3 months ago

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.

pumpkiiinnn commented 3 months ago

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

pumpkiiinnn commented 3 months ago

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

innovationmech commented 3 months ago

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

shouge commented 2 months ago

Me too

yueyangbo123 commented 4 weeks ago

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
markpollack commented 5 days ago

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