Spring AI 2.0 in Practice: Build a RAG Knowledge Base Q&A System in One Hour

A hands-on guide to building an enterprise RAG Q&A system with Spring AI 2.0 and Ollama local LLM deployment.
This article introduces a hands-on enterprise RAG Q&A system project built on the Spring AI 2.0 framework. The system adopts a Spring Boot + Vue 3 architecture, combining Ollama-deployed Qwen3 local LLM with Redis vector database to implement core features including document upload and parsing, automatic chunking and vectorization, semantic retrieval, and intelligent Q&A. The project supports local deployment to protect data privacy and serves as a reference case for Java developers getting started with AI application development.
Project Overview: Building an Enterprise-Grade RAG Q&A System with Spring AI 2.0
RAG (Retrieval-Augmented Generation) has become an essential technology for enterprises deploying large language model applications. This technology originated from Meta AI Research's 2020 paper Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, with the core motivation of solving two major pain points of purely generative LLMs: knowledge cutoff dates (training data has a limited time horizon) and hallucination issues (models tend to confidently generate incorrect information). In simple terms, RAG enables LLMs to stop "making things up" when answering questions — instead, they first retrieve relevant content from an enterprise knowledge base, then generate answers based on real materials. This is exactly the kind of "reliable AI" that enterprises need. In enterprise scenarios, this means AI can answer questions based on internal company documents, product manuals, policies, and other private knowledge bases without uploading sensitive data to model training sets.
The hands-on project introduced in this article builds a complete RAG enterprise knowledge base Q&A system using the Spring AI 2.0 framework, while leveraging Cursor AI as a programming tool to significantly boost development efficiency. The project adopts the classic architecture of a Spring Boot backend + Vue 3 frontend, combined with Ollama local LLM deployment and Redis vector database — making it an excellent reference case for Java developers getting started with AI application development.

Technology Stack and Architecture Design
Backend: Spring Boot + Spring AI 2.0
The backend is built on Spring Boot + Spring AI 2.0. Spring AI is a Java AI development framework launched by the Pivotal/VMware team in 2023. Its design philosophy is consistent with the Spring ecosystem — using abstraction layers to shield underlying differences, enabling developers to interface with different AI service providers through a unified API. Spring AI 2.0 significantly improved upon version 1.x with enhanced vector database support (covering over ten options including Redis, Pinecone, Weaviate, Chroma, etc.), Function Calling, multimodal input capabilities, and more. For Java developers, Spring AI's greatest value lies in eliminating the need to learn the Python ecosystem (LangChain/LlamaIndex) — you can complete full development of RAG, Agent, and other AI applications within the familiar Spring Boot system. It is currently the most mature AI development framework in the Java ecosystem.
For the database layer, MySQL 8 stores business data with MD5-encrypted passwords (default password: 123456), while session caching is handled by Redis.
LLM integration supports two approaches:
- Baidu Cloud Platform: Suitable for developers without local GPU resources, accessible via API calls
- Ollama Local Deployment: The primary approach demonstrated in this project, using Qwen3 (4B parameter version), which has low GPU requirements and can run on ordinary development machines
Ollama is a local LLM runtime framework that emerged in 2023, similar to "Docker" for large language models — you can pull and run various open-source models with simple command-line operations. Under the hood, it's based on llama.cpp and supports CPU/GPU hybrid inference, making it possible to run small-to-medium scale models on ordinary development machines without high-end GPUs. Qwen3 is an open-source LLM series from Alibaba Cloud; the 4B parameter version runs smoothly on machines with 8GB of memory and performs particularly well in Chinese comprehension and code generation. The core value of local deployment lies in data privacy protection — the vectorization of enterprise sensitive documents and Q&A inference are completed entirely locally without passing through any external APIs, meeting the strict data compliance requirements of industries such as finance, healthcare, and government.
The embedding model also uses the Qwen3 series, responsible for converting document content into vector representations. The vector database uses Redis Vector Store, running via Docker Desktop with a very straightforward deployment process. Since version 7.2, Redis natively supports vector storage and retrieval through the RedisSearch module. Compared to dedicated vector databases like Pinecone, Redis offers the advantages of simple deployment and reuse of existing caching infrastructure, making it ideal for small-to-medium enterprise knowledge base scenarios (sub-million vector scale).
Frontend: Vue 3 + Vite
The frontend is built with Vue 3 + Vite, featuring a clean and elegant interface design with rich data visualization charts. The system distinguishes between administrator and regular user roles, providing differentiated UI and feature permissions.

Core Feature Modules Explained
Knowledge Base Document Management
The system supports upload and parsing of knowledge base files in four common formats:
- TXT: Plain text files
- DOCX: Word documents
- PDF: PDF documents
- Markdown: Markdown format files
After document upload, the system automatically completes three steps: parsing, chunking, and vectorization, ultimately storing the vector data in the Redis vector database. The "chunking" step may seem simple, but it's actually one of the key factors determining RAG system quality. Chunks that are too large will result in retrieved context containing excessive irrelevant information, potentially exceeding the LLM's context window limit; chunks that are too small may break complete semantics, causing retrieved results to lack sufficient context. Common chunking strategies include: fixed-length chunking (splitting by character count or token count), semantic chunking (splitting at natural boundaries like paragraphs or sections), and sliding window chunking (adjacent chunks have overlapping regions to preserve boundary semantics). Spring AI 2.0 includes multiple TokenTextSplitter implementations, allowing developers to flexibly configure chunk size and overlap ratio based on document type.
Administrators can view the vector segment details of each document in the backend and manage documents by category. The project also thoughtfully provides test documents covering typical enterprise knowledge base scenarios such as API specifications, product user guides, company policies, and technical standards.
RAG Intelligent Q&A System
This is the core of the entire project. The retrieval principle of vector databases works as follows: the embedding model converts text into high-dimensional floating-point vectors (typically 512 to 4096 dimensions), semantically similar texts are closer in vector space, and the system uses approximate nearest neighbor algorithms like HNSW (Hierarchical Navigable Small World graphs) to complete semantic similarity searches in milliseconds. When a user asks a question, the system processes it through the following workflow:
- Convert the user's question into a vector using the embedding model
- Retrieve the most semantically relevant document segments from the Redis vector database
- Concatenate the retrieved context information with the user's question and send them together to the LLM
- The LLM generates an accurate answer based on the real knowledge base content
- Simultaneously display the referenced original text segments for user verification and traceability

The system also supports multi-document selective retrieval — users can specify searching within certain documents only, or choose to search the entire knowledge base. Each answer is annotated with its citation source, making the AI's responses "verifiable and traceable."
Related articles
TutorialsChatGPT Plus Subscription Guide: Are GPT-5.5, image-2, and Codex Worth the Upgrade?
A detailed look at ChatGPT Plus features — GPT-5.5, image-2, and Codex — with a Plus vs Pro comparison and a complete step-by-step subscription guide for users outside the US.
TutorialsHarness AI Engineering in Practice: Using Claude Code to Master Enterprise-Level E-Commerce Development
Deep dive into Harness AI Engineering: master enterprise e-commerce development with Claude Code using the Rules, Skills, Wiki, and Changes framework.
TutorialsCursor + Codex Dual-IDE Collaboration: A Practical Methodology for Open-Source Project Customization
A complete methodology for open-source project customization based on real-world experience, detailing the Cursor+Codex dual-IDE workflow, seven-stage process, MVP validation, and AI source code reading techniques.