
Explore the powerful mix of Spring and AI to build intelligent Java applications. Learn essential concepts, hands-on projects, and real-world use cases for integrating AI with Spring.
Explore the basics of artificial intelligence, defining AI as machines that simulate human intelligence and automate tasks from language understanding to image recognition and decision making in education.
Learn how machine learning trains systems from data to recognize patterns and make predictions or decisions. Discover supervised, unsupervised, and reinforcement learning with examples like spam classification and customer segmentation.
Transforming healthcare, finance, education, e-commerce, entertainment, and software development, AI enables Netflix recommendations, Amazon shopping personalization, fraud detection, chatbots, and realistic content generation.
Spring AI connects Java developers to AI models such as OpenAI, Huggingface, or local models, enabling text generation, summarization, translation, and image analysis within Spring Boot applications.
Explore how AI models learn patterns from large data to predict and generate text, images, or other outputs, and understand pre-trained models like GPT and their multi-type input processing.
Explore how language models process text into tokens through tokenization, revealing spaces, subword units, and punctuation, and discover how token boundaries impact cost, prompts, and model behavior.
Prompts are structured, multi-part communications with roles and context, beyond simple text. Prompt engineering blends art and science, using templates and Spring template patterns for reusable, maintainable, testable prompts.
Explore GPT, a generative pre-trained transformer, and how pre-training delivers accessible APIs, while Spring AI provides auto configuration, chat client API, and prompt templates.
Explore the OpenAI API by signing up for an OpenAI account, adding billing, and generating API keys, then integrate them into a spring boot project with practical examples.
Sign up for an OpenAI account by visiting the platform, selecting sign up, and continuing with Google or entering an email; log in if you already have an account.
Set up the OpenAI API billing by adding a payment method in your profile, selecting individual or company, entering card details, confirming, and viewing demo credits (e.g., $10).
Generate a secret key from the API keys dashboard after billing. Copy and securely store it, then use it in a Spring Boot app to access the Open API provider.
Trace the flow from browser requests to the Spring AI chat client, building the prompt with an API key, over HTTPS to the LLM provider, and back with AI response.
Explore the Spring AI chat client, a model-agnostic interface for interacting with AI models across providers; leverage builder patterns, dependency injection, and Spring Boot auto-configuration for seamless prompts and conversations.
Set up a Spring Boot quickstart chat app using web and OpenAI libraries, configure the API key via environment variables, and expose a simple chat endpoint.
Learn to create chat clients in a Spring Boot app with the auto-configured chat-client.builder for prototype, fresh instances. Or build directly from a chat model bin for manual control.
Create and configure chat clients using various approaches: implement a chat client config service, inject an open ai chat model, and compare in-code, config, and single-model setups.
Configure multiple llm chat clients by adding api keys for OpenAI and Entropic and wiring them with qualifiers or a primary bean to resolve which model to use.
Learn to wire and use multiple llm chat clients in Spring, qualifying each bean to run a single method that queries OpenAI and Entropic models via a simple controller endpoint.
Explore message types in spring ai to control ai behavior, format prompts, and enable tool calls. Learn system, user, assistant, function, and tool response messages for multi-turn conversations.
Configure a default system message in a Spring Java app by creating a chat client bean and a config class, then expose an api chat endpoint.
Externalize a large system message as a resource file using system message.txt, load it via app.config and class path, restart the application, and test with postman.
Explore how chat response provides the full AI output, including metadata and usage statistics, and learn to monitor tokens, the finish region, and multiple generations for cost and quality insights.
Build a minimal chat response workflow by wiring a service and controller to pass user input to a chat client prompt and an ask endpoint, then print the text output.
Explore generating a chat response and extracting metadata in a Java Spring AI app, including result text, finish reason, model name, and rate limit details.
Construct and display usage statistics for AI costs by querying a usage class, extracting prompt tokens, completion tokens, and total, via a simple endpoint demonstration.
Explore how to generate multiple variations of a response by adjusting max tokens, temperature, and n, then compare and choose the best with A/B testing in OpenAI chat.
Explore building a modular Spring application that uses question and answer models to generate recipes via a chat client, with a recipe generator service and a dedicated controller endpoint.
Explore prompt and prompt template fundamentals in Spring AI, mastering the prompt class, creating prompts from strings, messages, and lists, dynamic templates with placeholders, file loading, composition, and advanced patterns.
Explore the prompt class as the core data structure in Spring AI, packaging messages and options, with three creation modes from string, a single message, or a list.
Explore how to build prompts in Spring AI with different constructors, from string prompts to multi-message prompts, and use OpenAI chat options for controlled chat responses.
Learn to build reusable prompts with Prompt Template by using dynamic placeholders, external template files, and a builder-driven renderer to generate customizable system and user messages.
Demonstrates a basic prompt template usage in a Spring app by creating records for topic and level, and exposing a post endpoint to generate AI content.
Demonstrate generating a list via a prompt template with count, type, and topic placeholders, using a dto request, service, post endpoint, and curl test in a spring boot app.
Build a file-based template by creating a concept dto and prompts file, load the resource via class path, and expose a service and controller to handle concept requests.
Explore how to implement custom delimiters for JSON responses using angle brackets in a Java Spring Boot microservice, with a builder pattern and a prompt template.
Leverage Spring AI structured output to convert LLM responses into type-safe Java objects using automatic prompt formatting, JSON schema generation, and converters (bin, map, list) for Spring Boot.
Build a structured output converter in Spring Boot by creating REST endpoints that return list and map outputs via a conversion service, using a chat client and city capitals.
Learn how to model a movie as an object with title and release year, and generate a json list of director movies using a structured output template.
Explore an interactive html demo that runs in your browser with no installation, showcasing a list generator, a map converter, and a filmography generator with Java code and prompts.
Explore Spring AI advisors, interceptors for AI requests and responses, including chat memory advisors, the question answer advisor (RAG), and the safeguard advisor. Apply best practices for production-ready advisor implementations.
Explore how Spring AI advisors act as modular interceptors between app code and the model, enabling memory, safety filtering, and context injection via a configurable call-around-advisor chain.
Compare three Spring AI chat memory advisors: message memory stores history in memory, prompt memory injects history into prompts, and vector store uses semantic similarity for scalable context.
Learn how a question-answer advisor uses retrieval-augmented generation with a vector store to ground answers in retrieved documents and context, via similarity search.
Implement Safeguard Advisor to filter forbidden words in client prompts, reject disallowed requests as the first line of defense, and prompt users to rephrase, protecting content safety.
Discover Spring AI chat memory, turning stateless LLMs into stateful conversations with chat memory and history, via a pluggable chat memory repository and a sliding window for token limits.
Mastering spring ai's message window memory implements a windowed memory strategy that preserves system messages, keeps recent messages, and supports repository agnostic backends from in-memory to JDBC, Cassandra, or Neo4j.
Create a simple chat memory demo with a message window memory and max message; see how memory and default advisor shape responses.
Learn to implement a JDBC chat memory repository with an H2 database in a Spring app, including schema setup, H2 console access, and persisting chat history for future sessions.
Demonstrate a MySQL-backed chat memory using the JdbcChatMemoryRepository in a Spring AI project, with environment setup and a persistent chat schema. Compare persistence across restarts with MySQL Workbench and Postman.
Discover vector databases that store high-dimensional embeddings and use approximate nearest neighbor search to enable semantic search, recommendations, and AI-powered retrieval at scale.
Explore vector angles and cosine relationships to understand similarity in a vector database; near-zero angles yield cosine near one, perpendicular yields zero, and 180-degree angles yield cosine minus one.
Learn to compute cosine similarity between vectors using dot product and euclidean norms, illustrated with a=[1,2,3] and b=[4,5,6], yielding about 0.9746.
Visualize cosine similarity with vectors a and b, from orthogonal to opposite angles; change values to update the formula, with a GitHub repo for hands-on exploration.
Explore real-world cosine similarity with three examples—similar, unrelated, and opposite sentiments—illustrated by movie reviews and product descriptions, and apply it to search engines, recommendations, social media, and more.
Use the simple vector store for in-memory, non-persistent vector search in Spring AI, enabling testing and prototyping without external sources like Redis, chroma, or PG vector.
Explore vector databases such as Reddis, PG, Croma, and Mongo with Spring, demonstrating a unified vector store abstraction where embedding models and similarity searches stay consistent as only configuration changes.
Create and use a PGVector store in PostgreSQL with OpenAI embeddings. Build two Spring Boot projects for insertion and retrieval, configure docker Postgres, extensions, and perform cosine similarity searches.
Set up pgvector on ubuntu without docker by installing postgres, adding the repository, and enabling vector, store, and uuid-ossp extensions. Create a vector-enabled table and test remote access.
Install PGVector on Windows without docker by installing Visual Studio C++ build tools, PostgreSQL 17, pgAdmin, setting PG_ROOT, and cloning and building PGVector with Git.
Set up the chroma vector store with docker, load document embeddings and metadata, and perform similarity searches in a Spring Boot app using OpenAI embeddings and a local vector store.
Mastering Spring AI shows how Redis vector search works with Spring AI to enable fast hybrid queries by combining vector similarity with traditional filters using flat or HNSW algorithms.
Integrate Atlas vector search with Spring Boot to build a generative AI app, performing semantic searches over vector embeddings stored in MongoDB Atlas.
Explore how to leverage Cassandra as a vector database for cosine similarity search by storing document embeddings and performing fast similarity matching with a Spring Boot app and OpenAI embeddings.
Explore a Neo4j vector search demo in a Spring Java app, using NSW hierarchical index on embeddings to perform cosine-based similarity queries and return top results.
Explore implementing Oracle vector database vector search with a Spring Boot app, including docker usage, configuring vector store with cosine distance and IVF, loading data, and performing top-3 similarity searches.
Learn to build a Spring Boot app using the Milvus vector database, install Milvus on Ubuntu with Docker, configure a vector store, and perform cosine similarity searches with top results.
Explore how to implement a Typesense vector search in a Spring Boot Java app, embedding documents with OpenAI, and index using a Docker-based Typesense setup to perform similarity search.
Learn Weaviate vector search by storing objects and vectors and querying via GraphQL. A Spring demo loads JSON into the vector store and runs top-3 searches with a 0.7 threshold.
Learn to set up the quadrant vector database in a Spring Boot app with Docker, embedding storage, and vector-based search for product catalogs.
OpenSearch vector search demonstrated with a Spring Boot app, using Docker to run OpenSearch, load vectors from a JSON file, and perform vector search in Java.
Explore how Elasticsearch expands into a vector database, and follow a docker-based setup and spring boot vector demo with OpenAI integration.
Apply sql-like filter expressions in Spring AI to refine similarity search results, using multiple conditions—language, category, price, and rating—to tailor AI powered queries.
Set up pgvector with a dockerized PostgreSQL instance and initialize a Spring Boot project. Learn to store embeddings in a vector store and perform a basic similarity search without metadata.
Apply a metadata filter in a vector store by adding brand and product name, then build a filter expression to filter results by Apple.
Apply multiple filters with the and operator to refine search results by brand and price, using a practical laptop example with Apple and a price of $1000.
Explore greater than, less than, and their equal variants in Spring AI to refine product searches by price, using multiple filters with dynamic parameters.
Discover how to use the in, not in, and not operators with filter expressions to build queries, including example literals like Apple, Dell, and Samsung.
Explore building filter expressions with SQL-like syntax, using or and and operators, including inline and nested expressions, to filter products by price greater than 500 and other criteria.
Mastering Spring AI
Course Description
Dive into the cutting-edge world of AI integration with Spring Boot in this comprehensive course, “Mastering Spring AI”. Perfect for Java developers looking to enhance their applications with powerful AI capabilities, this course will guide you through the process of seamlessly incorporating artificial intelligence into your Spring projects.
What You’ll Learn:
Spring AI Fundamentals: Understand the core concepts of Spring AI and its integration with Spring Boot.
AI Model Integration: Learn to integrate and work with various AI models, including language models and image generation tools.
Image Processing and Generation: Explore image-related AI tasks within your Spring applications.
Vector Databases: Learn to use vector databases for efficient AI data storage and retrieval.
AI-Powered Search: Implement advanced search functionalities using AI techniques.
Prompt Engineering: Master the art of crafting effective prompts for optimal AI model responses.
Prerequisites:
Basic knowledge of Java and Spring Boot
Familiarity with RESTful API development
Understanding of basic AI concepts (helpful but not required)
Who This Course is For:
Java developers looking to integrate AI into their applications
Spring Boot enthusiasts interested in expanding their skillset
Software engineers aiming to stay current with AI trends in application development
Embark on this exciting journey to master Spring AI and transform your Spring applications with the power of artificial intelligence!