Spring AI, AI Security & Governance
Implementing chat, RAG, tools, MCP and memory with Spring AI 2.0, running it in production, and securing and governing enterprise AI.
This module turns the architecture of modules 1–3 into Java code with Spring AI 2.0 on Spring Boot 4, then covers what makes AI safe to run in a regulated enterprise: the OWASP Top 10 for LLM applications, prompt-injection defences, and governance frameworks such as the EU AI Act, NIST AI RMF and ISO/IEC 42001.
Articles
- Spring AI fundamentalsSpring AI 2.0 explained for Java architects: the portable model abstractions, ChatClient fluent API, prompt templates, streaming, structured output into Java records, the advisor chain, multiple models, and how it maps to the enterprise AI stack.
- Spring AI RAGImplementing RAG in Java with Spring AI 2.0: the ETL pipeline (DocumentReader, TokenTextSplitter, metadata enrichers, VectorStore), pgvector configuration, QuestionAnswerAdvisor, modular RetrievalAugmentationAdvisor with query rewriting, metadata and permission filters, and testing.
- Spring AI tools, MCP & memoryBuilding agents in Java with Spring AI 2.0: @Tool methods and ToolContext, the tool-calling loop and ToolCallingAdvisor, MCP client and MCP server starters with @McpTool, chat memory with JDBC repositories, human approval, and a complete agent example.
- Spring AI in productionRunning Spring AI services in production: Micrometer observations and OpenTelemetry tracing, token and cost metrics, evaluation tests with RelevancyEvaluator and FactCheckingEvaluator, Testcontainers, resilience, timeouts, virtual threads, configuration of models via an AI gateway, and a deployment reference.
- AI securitySecuring LLM and agentic applications: the OWASP Top 10 for LLM Applications (2025) explained with examples and mitigations, direct and indirect prompt injection, the lethal trifecta, design patterns that resist injection, agent-specific threats, data protection, red teaming and a secure reference architecture.
- AI governanceHow enterprises govern AI: responsible-AI principles, the EU AI Act risk tiers and obligations, NIST AI RMF and its generative AI profile, ISO/IEC 42001, model risk management in financial services, GDPR, the AI governance operating model, use-case lifecycle, documentation and controls mapped to architecture.