Part 4: Spring AI Building a RAG Pipeline

Part 4: Spring AI Building a RAG Pipeline

A Spring AI RAG pipeline lets an LLM answer using your documents instead of just its training data. RAG — retrieval-augmented generation — is three moves: take the user’s question, find the most relevant chunks from your data (using embeddings and a vector store), and send those chunks plus the question to the model. The model answers grounded in what you gave it. Spring AI’s ChatClient and document/vector abstractions make this surprisingly little code. This is Part 4 of the Spring AI series and it ties the previous parts together. ...

Part 3: Spring AI Embeddings and Vector Stores

Part 3: Spring AI Embeddings and Vector Stores

RAG rests on two primitives: embeddings (turning text into vectors) and a vector store (saving those vectors and finding the nearest ones to a query). Spring AI gives you one interface for each — EmbeddingModel and VectorStore — and you choose the implementation with a dependency and config, exactly like the chat client in Part 2. This is Part 3 of the Spring AI series, and it’s the groundwork for the RAG pipeline in Part 4. ...

Part 2: Spring AI Chat Completions with OpenAI or Ollama

Part 2: Spring AI Chat Completions with OpenAI or Ollama

With Spring AI on the classpath, calling a chat model comes down to three things: add the right starter, set an API key or base URL in config, and inject ChatClient. The same Java code then works whether you’re hitting OpenAI in the cloud or a local Ollama model on your laptop — you swap the dependency and the config, not the logic. This is Part 2 of the Spring AI series. ...

Part 1: Introduction to Spring AI

Part 1: Introduction to Spring AI

Spring AI brings AI capabilities into the Spring ecosystem as a first-class citizen. Instead of hand-rolling HTTP clients for OpenAI, Anthropic, or Ollama and wiring JSON parsing, retries, and secrets yourself, you get a consistent abstraction over chat models, embeddings, and vector stores — with the usual Spring benefits: dependency injection, configuration properties, auto-configuration, and optional observability. If you already think in @Service and application.yml, Spring AI will feel immediately familiar. This is Part 1 of a four-part series that ends with a working RAG app. ...

Going Async: Painless REST APIs with Spring WebFlux

Going Async: Painless REST APIs with Spring WebFlux

Spring WebFlux is the reactive, non-blocking sibling of Spring MVC. Instead of one thread per request blocking on I/O, WebFlux runs on a small event-loop and frees the thread while it waits for the database or another service to answer. Built on Project Reactor, it’s a great fit for high-concurrency APIs and reactive data sources — but it’s not a free upgrade, and that nuance is the most important thing to get right. ...

Surviving & Thriving on Day 1 with Spring Boot 3

Surviving & Thriving on Day 1 with Spring Boot 3

Getting started with Spring Boot 3 is mostly the familiar Spring experience with a few hard requirements you can’t skip. The big two: Java 17 is the new minimum, and the whole framework moved from the javax.* namespace to jakarta.*. If you’re starting fresh, you barely notice. If you’re upgrading from Boot 2, those two facts explain 90% of the migration pain. Let’s get you running, then cover what changed. ...

Spring Boot Exception Handling That Doesn't Make You Cry

Spring Boot Exception Handling That Doesn't Make You Cry

Good Spring Boot exception handling means your API fails predictably. Out of the box, an unhandled exception gives the client either a wall of HTML (the Whitelabel Error Page) or a JSON blob that leaks your package names and stack trace. Both are bad: ugly for your frontend, and a small gift to attackers. The fix is to handle errors in one place with @RestControllerAdvice and return a consistent error body. Here’s the version I actually ship. ...

Your First Spring Boot REST Controller in 5 Minutes

Your First Spring Boot REST Controller in 5 Minutes

You want to ship an API. You don’t want to hand-configure Tomcat, write a web.xml, or fight a servlet container. A Spring Boot REST controller gets you from zero to a working HTTP endpoint in about five minutes — and this guide is the copy-paste-run version, plus just enough explanation that you actually understand what you pasted. What you need first One dependency: spring-boot-starter-web. Add it to your pom.xml (or build.gradle) and Spring Boot pulls in Spring MVC, Jackson (for JSON), and an embedded Tomcat. That last part is the magic — there’s no external server to install or deploy to. Your app is the server. Generate a skeleton at start.spring.io if you don’t have one (more on that in Surviving Day 1 with Spring Boot 3). ...