Spring AI Day 14: Full Knowledge Map and Interview Checklist
This article presents a panoramic knowledge map of Spring AI 2.0, outlines core components, dependency configurations, key APIs for chat, RAG and tool integration, and provides a concise interview Q&A guide to help developers verify their mastery of the framework.
14 days of learning, concepts scattered everywhere. The final article assembles them into a comprehensive diagram and provides interview questions to test real understanding.
Panoramic Knowledge Map
The Spring AI application can be broken into three layers—basic invocation → knowledge augmentation → capability extension—plus a cross‑cutting aspect mechanism:
Spring AI 2.0
│
┌───────────────┬───────┴────────┬────────────────┐
│ │ │ │
基础调用 知识增强(RAG) 能力扩展 横切机制
│ │ │ │
ChatClient Embedding @Tool/@ToolParam Advisors
(Day1-2) + VectorStore (Day7) (Day12)
│ │ │ │
Prompt template 文档 ETL(Day9) client/server Chat Memory
(Day3) MCP (Day6) (Day13)
│ │ │
RAG 问答(Day10) 结构化输出
│ │
模块化 RAG(Day11)
│
多模态(Day5)
底层模型:DeepSeek / OpenAI / 通义 / 智谱 / Ollama(换 starter,不换调用代码)One‑sentence summary: Use ChatClient to call models, attach abilities with Advisors, feed knowledge via RAG, and connect external tools with @Tool / MCP.
Core Quick Reference
BOM : spring-ai-bom:2.0.0-M8 Milestone repository : https://repo.spring.io/milestone Conversation starter : spring-ai-starter-model-deepseek Embedding starter : spring-ai-starter-model-transformers MCP starter :
spring-ai-starter-mcp-clientAPI Usage
prompt().user(x).call().content()– synchronous call returning plain text. .call().chatResponse() – returns full response with token usage. .stream().content() – streaming output as Flux<String>. .entity(Xxx.class) – structured output as a Java object. .system() / .user(u -> u.param()) – role setting and template parameters. .options(ChatOptions.builder()...) – per‑call model parameter override.
RAG and Tools
VectorStore.similaritySearch(SearchRequest)– semantic search. vectorStore.accept(splitter.apply(reader.read())) – ETL into vector store. QuestionAnswerAdvisor.builder(vectorStore) – simple RAG. RetrievalAugmentationAdvisor.builder() – modular RAG. @Tool / @ToolParam / .tools(object) – tool calling. .defaultToolCallbacks(mcpTools) – integrate MCP tools.
Frequently Asked Interview Questions
Q1: Relationship between ChatClient and ChatModel? ChatModel is the low‑level interface exposing call(Prompt); ChatClient is a high‑level fluent façade that wraps ChatModel and adds prompt templates, advisor chains, structured output, and streaming. Use ChatClient for everyday development.
Q2: When to choose call() vs stream() ? call() waits for the model to finish and returns the complete result – suitable for background tasks. stream() returns a Flux and pushes tokens as they are generated – ideal for chat UI typing effects.
Q3: How to make the model return a Java object? Use .entity(Xxx.class). Internally BeanOutputConverter adds a JSON schema to the prompt, forcing the model to output JSON that is then deserialized. For collections, supply a ParameterizedTypeReference to bypass type erasure.
Q4: What is an Advisor and which built‑ins exist? Advisors are interceptors in the LLM call chain, allowing pre‑ and post‑processing. Built‑ins include MessageChatMemoryAdvisor (memory), QuestionAnswerAdvisor (RAG), SimpleLoggerAdvisor (logging), and SafeGuardAdvisor (content safety).
Q5: How does a large model retain multi‑turn conversation? What is conversationId ? The model itself is stateless; MessageChatMemoryAdvisor stores prior messages in the prompt. conversationId isolates memory per user or session, typically set to the user ID.
Q6: Full RAG workflow and why chunk documents? Offline: document → read → chunk → embed → store in vector DB. Online: query → embed → retrieve relevant chunks → inject into prompt → generate. Chunking avoids exceeding context length and reduces irrelevant retrieval, mitigating hallucinations and stale knowledge.
Q7: Difference between QuestionAnswerAdvisor and RetrievalAugmentationAdvisor ? The former is a “quick‑start” RAG that directly retrieves using the original user query. The latter is modular, exposing components like QueryTransformer, DocumentRetriever, and QueryAugmenter for production‑grade tuning.
Q8: How does Tool Calling work? Does the model execute my method? The model only requests a tool call, returning the tool name and parameters. Spring AI then invokes the corresponding Java method and feeds the result back to the model for the final answer. The @Tool description guides the model’s decision.
Q9: When to use @Tool vs MCP? @Tool exposes custom Java methods – ideal for internal business logic. MCP connects to existing tool ecosystems (file system, database, GitHub, etc.) with plug‑and‑play support and can be shared via an MCP Server.
Q10: Main changes from Spring AI 1.x to 2.0? The biggest change is modular refactoring into independent artifacts such as spring-ai-client-chat, spring-ai-vector-store, and spring-ai-rag. Starters follow the pattern spring-ai-starter-model-<vendor>. Version 2.0 is currently a milestone preview; production should stay on 1.1.x GA.
Final Thoughts
In 14 days you can progress from a simple prompt().call() to a full AI application with memory, RAG, and tool calling. The core principle of Spring AI is: "Abstract AI capabilities as Spring‑style components; swap models without changing code, add abilities by attaching Advisors."
Resources
https://docs.spring.io/spring-ai/reference/ https://github.com/spring-projects/spring-ai https://platform.deepseek.com/Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Tech Ocean
Focused on AI programming, sharing ready-to-use development efficiency solutions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
