
Welcome to the course! In this introduction you'll see what we're going to build, how the course is structured, and how Spring AI lets Java developers move from traditional applications to AI-native ones.
Get to know your instructor, their background in Java and AI, and why this course was created. You'll also learn how to get the most out of the lectures, quizzes, and hands-on exercises.
Discover what the Spring AI framework is and the problems it solves. We'll cover its core abstractions, such as ChatClient, models, prompts, and advisors, and how it brings generative AI into familiar Spring Boot applications.
Compare building AI applications with Spring AI versus Python-based frameworks. You'll learn where each ecosystem shines and why Spring AI is a strong choice for enterprise Java teams that want to add AI to existing systems.
Prepare your environment to follow along with the course. We'll go over the required tools, JDK version, and project setup so you can run every example on your own machine.
Learn how students can get a free JetBrains educational license for IntelliJ IDEA Ultimate. We'll walk through the application process so you can use the full-featured IDE throughout the course.
See how Docker Desktop is used in this course to run supporting services such as databases, vector stores, and local LLMs. You'll install Docker Desktop and verify that it's ready for the hands-on lectures.
Compare Gradle and Maven, the two main build tools in the Java ecosystem. You'll understand the trade-offs between them and why we chose the build tool used for the course project.
Get an intuitive introduction to Large Language Models (LLMs) and what makes them so powerful. We'll cover what LLMs are, how they're trained, and what they can and can't do for your applications.
Understand the core mechanism behind LLMs: predicting the next token. You'll see how this simple idea produces fluent text, and why it explains both the strengths and the limitations, such as hallucinations, of generative AI.
Learn what tokens are and how LLMs split text into them. We'll cover why tokens matter for context window limits, response length, and the cost of every request you send to a model.
I this lecture we will review Prompts in Spring AI:
They are Views: Treat prompts as dynamic views that map your application data to LLM-ready inputs.
They are Structural Containers: A Prompt object safely houses multiple role-based Message objects and configuration ChatOptions.
They are Decoupled: Always use PromptTemplate and placeholders to separate layout logic from dynamic data.
Learn how to control model behavior with ChatOptions in Spring AI. We'll cover key parameters such as model selection, temperature, top-p, and max tokens, and how each one affects the model's responses.
Create a new Spring AI project from scratch with Spring Initializr. You'll select the right dependencies, generate the project, and open it in your IDE, ready for the first AI call.
Clone the course project from Git so you can follow along with every lecture. We'll go over the repository layout and how to switch between the code for each section.
Explore the multi-module structure of the course project. You'll see how each topic lives in its own module, which keeps the examples independent and easy to run on their own.
Make your first real conversation with Google Gemini using Spring AI. You'll send a prompt through ChatClient, receive the model's answer, and see how little code it takes to add AI to a Spring Boot app.
Create a Gemini API key in Google AI Studio so your application can authenticate with the Gemini API. We'll also cover how to keep the key safe and out of your source code.
Configure your Gemini API key globally using environment variables so every module in the project can use it. You'll learn a clean, secure setup that works across your IDE and terminal.
Learn the first way to inject a system prompt directly in code. You'll see how system prompts set the model's role, tone, and rules, and how they shape every response that follows.
Explore the second and third ways to define system prompts in code with Spring AI. We'll compare these approaches so you can choose the cleanest option for your use case.
Define a default system prompt once in a ChatClient @Bean and reuse it across your application. This keeps the model's behavior consistent and removes repeated prompt code.
Load the system prompt from an external resource file instead of hard-coding it. You'll learn how to keep prompts separate from Java code so they're easier to maintain, version, and update.
Configure LLM options such as model, temperature, and max tokens in application.yml. You'll see how Spring Boot properties let you change model behavior without touching the code.
Configure ChatOptions with a Spring @Bean for full programmatic control. You'll learn when a bean-based configuration is better than properties, and how to set defaults for your ChatClient.
Set ChatOptions directly in code for an individual request. You'll see how to override the default settings per call, for example using a different temperature for creative and factual tasks.
Stream the LLM's response token by token instead of waiting for the full answer. You'll use Spring AI's streaming support with Reactor Flux to build faster, more responsive AI experiences.
Look inside Spring AI Advisors, the middleware layer that wraps every call to the model. You'll learn the advisor chain architecture and how advisors can modify requests and responses along the way.
Discover recursive advisors and how they enable autonomous AI loops in Spring AI. We'll cover how an advisor can call the model repeatedly, for example to retry or refine an answer until it meets your criteria.
Build your first advisor using Spring AI's SimpleLoggerAdvisor to log requests and responses. This first part covers setup and shows exactly what is sent to and received from the model.
Continue working with the logging advisor and customize what gets logged. You'll learn how to configure log levels and formats to make debugging AI calls much easier.
Use Spring AI's built-in SafeGuardAdvisor to block sensitive or unwanted words before they reach the model. You'll see how to add a simple safety layer to your application with a few lines of code.
Build your own custom safeguard advisor with rules tailored to your application. You'll learn how to implement the advisor interfaces and plug your custom logic into the advisor chain.
Learn how to share dynamic state between advisors using the advisor context. You'll see how to pass data along the chain, so advisors can work together on a single request.
Understand why structured output matters when connecting LLMs to type-safe Java code. We'll cover how Spring AI converts free-form model responses into Java objects you can use directly in your application.
Get a simple list back from the model with Spring AI structured output. You'll learn how to ask the LLM for a list and receive it as a ready-to-use Java List.
Convert the model's response into a Java Map with Spring AI structured output. You'll see when a flexible key-value structure is the right choice for the data you get back.
Map LLM responses directly into Java Beans and records. You'll learn how Spring AI generates a JSON schema from your class and converts the model's output into a strongly typed object.
Work with complex, nested Java Beans as structured output. You'll learn how to handle lists of objects and nested types so the model returns rich, realistic data structures.
Use a validation advisor to check that the model's structured output is valid. You'll see how invalid responses can be detected and automatically retried, making your AI features more reliable.
Build a custom validation advisor with your own business rules for structured output. You'll learn how to reject responses that don't meet your requirements and ask the model to correct them.
Learn how to use provider-native structured output, where the model provider itself enforces the JSON schema. We'll compare this approach with Spring AI's converters and when to use each one.
Understand why you might run LLMs locally instead of in the cloud. We'll cover the benefits for privacy, cost, and offline development, along with the hardware and model-size trade-offs.
Install Ollama and download your first local model. You'll learn how to run and test a model from the command line before connecting it to Spring AI.
Connect Spring AI to a local model running in Ollama. You'll see how easily you can switch from a cloud provider to a local LLM by changing the dependency and configuration.
Run your local LLM inside Docker Desktop instead of a native install. You'll learn how containerized models make your setup portable and easy to share with your team.
Understand why LLMs are stateless and how chat memory gives them the context of a conversation. We'll cover the core concepts behind Spring AI's ChatMemory and the memory advisors.
Add conversation memory to your application with Spring AI's default in-memory implementation. You'll see how the model remembers earlier messages and how conversations are separated by conversation ID.
Learn how the context window limits how much history you can send to the model. You'll use a message window to keep only the most relevant recent messages and control token usage and cost.
Prepare a database-backed chat memory repository using Docker Compose. You'll define the services in compose.yaml so the database starts automatically with your application.
Set up a PostgreSQL database to store chat memory persistently. You'll get Postgres running and ready so conversations survive application restarts.
Connect Spring AI to PostgreSQL using the JDBC chat memory repository. You'll configure the data source and schema so chat history is saved to the database.
Work with chat memory stored in Postgres in a running application. You'll test multi-turn conversations, inspect the stored messages, and see how history is loaded for each request.
Learn best practices for chat memory in production. We'll cover choosing the right storage, limiting history size, isolating users' conversations, and keeping sensitive data safe.
Understand embeddings, the numeric vectors that capture the meaning of text. You'll see how similar ideas end up close together in vector space, which is the foundation of semantic search and RAG.
Compare RAG (Retrieval-Augmented Generation) and CAG (Cache-Augmented Generation) as ways to give your LLM knowledge. You'll learn the trade-offs and how to choose the right data architecture for your application.
Meet "The Researcher": how RAG connects LLMs to live, up-to-date data at query time. You'll see how relevant documents are retrieved and added to the prompt so the model answers from your data.
Meet "The Librarian": how CAG pre-loads knowledge into the model's context ahead of time. You'll learn when caching a fixed knowledge set is faster and simpler than retrieving data on every request.
How do AI chatbots intuitively understand your intent, even when you use messy language? In this lecture, we demystify the core concepts behind semantic search and modern AI context retrieval: Vector Databases and Cosine Similarity.
Skipping complex mathematical jargon, we use clear, practical analogies to show how AI transforms human text into directional arrows (Vectors) on a conceptual map. You will learn how systems calculate the angles between these arrows to find perfect contextual matches in milliseconds.
Key topics:
Text to Vector: Understanding text embeddings.
The Power of Angles: Why a tiny angle equals high similarity.
Vector DBs: Serving accurate context instantly.
Get an introduction to vector databases and the architecture behind them. You'll learn how they store embeddings, index them for fast similarity search, and why they're a core part of modern AI applications.
See how Spring AI works with vector databases through its VectorStore abstraction. You'll learn how one common API lets you add, search, and switch vector stores without rewriting your code.
Connecting the Dots: Mastering Multi-Hop Complex Relationships in AI & RAG Discover why standard vector databases fail when corporate data is deeply interconnected. In this lecture, we break down what "multi-hop" relationships are using a real-world compliance example and explore how GraphRAG and graph databases like Neo4j allow AI to connect the dots across separate data silos.
Learn why hybrid search, which combines semantic vector search with traditional keyword search, often gives better results. We'll cover where pure vector search falls short and how hybrid search fixes it.
Set up the infrastructure for your vector store with Docker. You'll get the vector database running and connected to your Spring AI project.
Create vectors from text with an embedding model in Spring AI. You'll see how documents are turned into embeddings and stored in the vector store.
Ingest CSV data into your vector store. You'll read the records, convert them into documents, embed them, and load them so they're ready for semantic search.
Build a working RAG flow using similarity search on your vector store. You'll retrieve the most relevant documents for a question and let the LLM answer based on them.
Ingest PDF documents into the vector store using Spring AI's document readers. You'll learn how PDFs are read, split into chunks, embedded, and stored for retrieval.
Use metadata filters to route and narrow down your vector searches. You'll learn how to return only relevant documents, for example by category or source, to make RAG answers more precise.
Create multiple vector stores in the same application to keep different data sets separate. You'll configure each store and load it with its own content.
Route each question to the right vector store when you have multiple knowledge sources. You'll build routing logic so every query searches the most relevant data.
Review everything you've built with vector stores in this section. We'll recap ingestion, embeddings, similarity search, filtering, and multi-store routing, and how they fit together in a RAG pipeline.
Explore the vector stores supported by Spring AI, such as PGVector, Redis, Chroma, Pinecone, and others. You'll learn how to choose the right vector store for your scale, budget, and existing infrastructure.
Understand the full tool calling lifecycle: how the model decides to call a tool, how Spring AI executes it, and how the result goes back to the model. You'll also learn how to declare tools in your code.
Learn how tools are registered with Spring AI and how you control the flow of tool execution. You'll see the options for making tools available to the model and for handling their results.
Define and register tools programmatically instead of with annotations. You'll learn when this approach is useful, for example when tools are created dynamically at runtime.
Prepare for the tool calling examples by setting up the Finnhub stock market API. You'll create an API key and test the endpoints that our tools will call.
Turn regular Java methods into AI tools with the @Tool annotation. You'll let the model call your methods to fetch live data, such as stock quotes from Finnhub.
Discover how Spring AI generates a JSON schema for each tool so the model knows how to call it. You'll learn how parameter names and descriptions affect the model's ability to use your tools correctly.
Use the returnDirect option to send a tool's result straight to the user without passing it back through the model. You'll see when this saves tokens and latency and keeps results exact.
Configure tools directly in ChatClient, either as defaults for every call or for a single request. You'll learn how to control which tools are available in each conversation.
Define tools with MethodToolCallback for full programmatic control over how a method becomes a tool. You'll see how to set the tool's name, description, and input schema yourself.
Pass extra context into your tools with ToolContext, such as the current user or tenant ID. You'll learn how to give tools the information they need without exposing it to the model.
Learn how to handle errors in tool calling gracefully, so a failing tool doesn't break the whole conversation. We'll also cover best practices for designing safe, reliable, and well-described tools.
Get an overview of the Model Context Protocol (MCP), the open standard for connecting AI applications to tools and data. You'll learn why MCP matters and how its client-server architecture works.
Understand the MCP client: how it connects to servers, discovers their tools, resources, and prompts, and makes them available to your LLM. We'll cover the main client concepts and transports.
Understand the MCP server: how it exposes tools, resources, and prompts to any MCP client. You'll learn the server's capabilities and the transport options, such as STDIO and HTTP.
Take a guided tour of the official MCP documentation. You'll learn where to find the specification, SDKs, and examples so you can keep exploring on your own.
Set up an MCP client in your Spring AI project with the Spring AI MCP starter. You'll add the dependencies and configuration needed to connect to MCP servers.
Connect your Spring AI MCP client to the Node.js filesystem MCP server running locally. You'll let the LLM read and work with files through MCP tools.
Use the MCP Inspector to test and debug MCP servers. You'll learn how to list a server's tools, resources, and prompts, call them manually, and troubleshoot problems before connecting your app.
Run the Sequential Thinking MCP server in Docker and connect it to your Spring AI client. You'll see how this server helps the model work through complex problems step by step.
Connect your MCP client to a Finnhub MCP server running in Docker. You'll give the LLM live stock market data through MCP tools instead of writing the tools yourself.
Connect your MCP client to a remote MCP server over the Streamable HTTP transport. You'll learn how remote servers differ from local STDIO servers and how to configure the connection.
Use the asynchronous MCP client for non-blocking, reactive applications. You'll see how the async client differs from the sync client and when to choose it.
Build your own MCP server with Spring AI using the STDIO transport. You'll expose Java methods as MCP tools that any MCP client can discover and call.
Add static resources to your MCP server so clients can read fixed data such as documents or configuration. You'll learn how resources differ from tools.
Expose static prompt templates from your MCP server. You'll see how reusable prompts help clients and users interact with your server in a consistent way.
Build a synchronous MCP server over HTTP so remote clients can connect to it over the network. You'll configure the HTTP transport and test the server's tools.
Add dynamic resources to your HTTP MCP server using URI templates. You'll learn how clients can request resources with parameters and get data generated at request time.
Add prompt templates with arguments to your HTTP MCP server. You'll see how clients fill in the parameters to get ready-to-use prompts from your server.
Build an asynchronous MCP server with the Streamable HTTP transport. You'll learn how the async, non-blocking server handles more concurrent clients efficiently.
Expose resources and prompts from your asynchronous Streamable HTTP MCP server. You'll bring together tools, resources, and prompts in one reactive server.
Add completion capabilities to your MCP server so clients get suggestions for prompt and resource arguments. You'll see how this improves the experience for users of your server.
Connect your own MCP client to your own MCP server over STDIO. You'll see the full end-to-end flow, from the LLM's request through the client to the tools on your server.
Use your MCP client to read resources from your MCP server. You'll complete the end-to-end picture by working with server resources, not just tools.
Understand why observability is essential for AI applications in production. We'll cover the metrics, traces, and logs you need to monitor latency, token usage, cost, and errors.
Get started with Spring Boot Actuator to expose health and metrics endpoints. You'll add Actuator to the project and explore the built-in endpoints.
Explore the metrics exposed by Actuator and Micrometer, including the AI-specific metrics Spring AI provides. You'll learn how to read token usage and model call metrics for your application.
Get introduced to Prometheus and set it up to scrape your application's metrics. You'll run Prometheus with Docker and confirm it's collecting data from your Spring AI app.
Query your application's metrics in Prometheus with PromQL. You'll write queries to track requests, latency, and token usage over time.
Get introduced to Grafana and set it up alongside Prometheus. You'll connect Prometheus as a data source so you can start visualizing your metrics.
Build a Grafana dashboard to monitor your Spring AI application. You'll create panels for key metrics such as request rate, latency, and token usage, so you can see how your AI features behave.
AI Disclosure: This course contains the use of artificial intelligence.
Transform into a Senior AI Engineer with the Most Modern Tech Stack in the Java Ecosystem.
Generative AI is no longer just a trend—it is shifting the foundation of enterprise software architecture. Traditional Java applications are rapidly evolving into intelligent, AI-native systems capable of autonomous reasoning, real-time context retrieval, and complex task execution.
This course is engineered specifically for Java developers, backend engineers, and solution architects who want to step into the future of software development. You won't just learn how to connect an API to a chatbot; you will master the art of designing and building complex, autonomous, and cost-effective enterprise AI applications using the latest standards: Spring AI 2.0.0
What You Will Learn in the Course:
The Shift to AI-Native: Understanding the fundamental architectural transition required to upgrade traditional Spring architectures to support heavy generative capabilities.
Retrieval-Augmented Generation (RAG): Learn how to securely connect your private enterprise data to Large Language Models (LLMs) such as Gemini using high-performance vector databases.
Autonomous AI Agents and Tool Calling: Moving beyond passive chatbots. Learn how to build proactive AI agents capable of automatically selecting and executing internal Java functions (Tool Calling) to interact with your databases, external APIs, and business logic in real time.
Model Context Protocol (MCP): Master the open protocol that has become the industry standard for AI data integration. Learn how to implement MCP to grant your language models unified and secure access to data sources, enterprise systems, and developer tools without needing to rewrite complex middleware.
Prompt Engineering and Structured Outputs: Master the art of programmatically writing precise prompts and forcing language models to return well-defined, type-safe Java objects instead of raw, unpredictable text.
Token Metrics and Cost Optimization: Take a deep dive into how tokens work behind the scenes, how to build custom wrappers for language models, and how to programmatically track, monitor, and reduce API costs to save significant amounts of money.
By the end of the course, you won't just be a developer writing traditional Java code—you will be an AI engineer who knows how to design and build complex, secure, autonomous, and cost-effective intelligent applications.
Stop watching the AI revolution from the sidelines. Upgrade your Java stack, master Spring AI, and start building the future of enterprise software today!