Use AI models in Java the way you already use databases. <p/>Spring AI gives you one API for chat models, embeddings, vector stores and tools, and swaps the provider with a property. This book teaches it by building, not by listing features: thirteen chapters, seventeen complete Spring Boot projects, and every program run on a free local model and on a paid cloud model before a word was written about it. <p/>What you build
- A support desk that streams its replies, and a router that falls back to a local model when the cloud call fails
- An invoice parser that returns Java records, with the numbers checked in plain Java
- A duplicate-ticket detector using embeddings and cosine similarity, with no vector database at all
- Semantic search over a product catalogue on PostgreSQL with pgvector
- Question answering over your own PDFs, including why chunk size decides answer quality
- An order assistant that queries a database and calls a live web API, with an approval gate
- An MCP server that offers your application's tools to other AI applications
- A four-layer test suite for answers that change on every run
- Token, cost and latency accounting per feature, and a production checklist
Written against a verified stack
>Also included
- Appendix A: 113 gotchas by topic, with the exact error text, so you can search for the message on your screen
- An index, and a complete Maven project per chapter that opens in IntelliJ and runs with nothing but an API key, or nothing at all on a local model
Who it is for
Java and Spring Boot developers. No machine-learning background needed.