Spring / Spring Boot 4 Basics Interview Questions
What is Spring AI and how does it integrate with Spring Boot 4?
Spring AI is a first-class Spring ecosystem project that reached 1.0 GA in May 2025 and is now on a 2.x development track. It provides a model-agnostic abstraction layer for integrating LLMs, vector stores, and AI pipelines into Spring Boot 4 applications.
| Concept | Description |
|---|---|
| ChatModel | Abstraction over LLM providers (OpenAI, Gemini, Anthropic, Mistral, Ollama, etc.) |
| EmbeddingModel | Generates vector embeddings from text |
| VectorStore | Auto-configured integration with 10+ vector databases (pgvector, Pinecone, Chroma, Weaviate, etc.) |
| ChatClient | Fluent API for building prompt chains, advisors, and tool calling |
| Tool calling | LLMs can invoke Spring beans as tools (@Tool annotation) |
| MCP support | Model Context Protocol server integration |
| RAG pipelines | QuestionAnswerAdvisor for retrieval-augmented generation |
// Spring AI: ChatClient in Spring Boot 4 @Service public class CustomerSupportService { private final ChatClient chatClient; public CustomerSupportService(ChatClient.Builder builder, VectorStore vectorStore) { this.chatClient = builder .defaultSystem("You are a helpful customer support agent.") .defaultAdvisors( // RAG: retrieve relevant documents before answering new QuestionAnswerAdvisor(vectorStore), new MessageChatMemoryAdvisor(new InMemoryChatMemory()) ) .build(); } public String answer(String question) { return chatClient.prompt() .user(question) .call() .content(); } } // Tool calling: LLM can call Spring beans as tools @Service public class OrderTools { @Tool(description = "Get the current status of an order by its ID") public String getOrderStatus(String orderId) { return orderService.findById(orderId).status().name(); } } # application.yml: Spring AI OpenAI configuration spring: ai: openai: api-key: ${OPENAI_API_KEY} chat: options: model: gpt-4o-mini temperature: 0.7
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
