What if you could build an AI assistant with access to your own data in under 40 lines of Java? That’s now possible with my contribution to the just-released Spring AI 2.0.0 M2 - Amazon Bedrock Knowledge Base support. It’s a fully managed RAG (Retrieval-Augmented Generation) service that handles document ingestion, embeddings, and vector storage for you - and now you can use it with Spring AI! RAG lets AI models answer questions using your own documents instead of relying solely on their training data.
In this post, I’ll show you how to build a working AI agent with RAG in minutes using JBang - no Maven project setup required. You’ll have an AI assistant answering questions from your company documents with minimal code.
Why Bedrock Knowledge Base?
Three things make this integration compelling:
Fully Managed: AWS handles document chunking, embeddings, and vector storage. No PGVector or OpenSearch to manage.
Read-Only from Spring AI: Documents sync via AWS - your app just queries. Simple.
Fast Setup: Connect S3, Confluence, or SharePoint as data sources. Sync and go.
Key features:
Search Types: SEMANTIC uses vector similarity; HYBRID combines semantic with keyword search for better recall
Reranking: Re-scores results using Bedrock reranking models to surface the most relevant documents
Metadata Filtering: Narrows results by document attributes (e.g., department == 'HR' && year >= 2024)
Similarity Threshold: Filters out low-relevance matches below a minimum score
JBang lets you run Java files directly - no pom.xml, no project structure. Perfect for quick experiments and demos. Dependencies are declared as comments in the source file.
That’s it. The JBang header declares dependencies, Spring AI auto-configures the VectorStore bean from the environment variable, and QuestionAnswerAdvisor handles RAG automatically.
Key Points
No EmbeddingModel needed: Unlike PGVector, Bedrock KB handles embeddings internally. If you’d like to build RAG with PostgreSQL and PGVector instead, check out my previous post.
Auto-configuration: Just set SPRING_AI_VECTORSTORE_BEDROCK_KNOWLEDGE_BASE_KNOWLEDGE_BASE_ID
QuestionAnswerAdvisor: Automatically retrieves relevant documents and adds them to the prompt
With minimal setup - one Java file and a few shell commands - you have an AI assistant grounded in your own data. No vector database to manage, no embedding pipeline to build.
I’m proud to have contributed this integration to Spring AI 2.0.0 M2. The source is available on GitHub if you want to see how it works under the hood.