Software Integration Series: DynamoDB Integration with Spring Boot

Swathi Prasad
5 min readMay 1

A simple guide to integrating Serverless NoSQL database with a Spring Boot application.

Photo by Jan Antonin Kolar on Unsplash

DynamoDB is a serverless, NoSQL database offered by AWS. It is a fully managed database and offers reliable performance at any scale. It scales up or down automatically to adjust for capacity and maintain performance.

In this article, we will learn how to easily integrate DynamoDB with a Spring Boot application.

Prerequisites

  • Apache Maven
  • Docker Desktop
  • IDE
  • AWS CLI

In this tutorial, we will use docker version of DynamoDB for local integration and testing. Download and Install docker desktop.

Follow the AWS documentation to install AWS CLI.

Maven Dependencies

Let’s create a sample Spring Boot application and include the following dependencies in pom.xml.

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.12.459</version>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>

</dependencies>

Spring Boot Starter Web dependency is used for building web or RESTful applications using Spring MVC. AWS SDK for DynamoDB provides APIs to work with DynamoDB. Lombok is used for generating boilerplate code such as getters, setters, and so on. JavaBeans Validation (validation-api) can add constraints to the beans with annotations placed on fields, methods, or classes.

There are various ways to install DynamoDB for local testing. Checkout the official documentation. We will install the docker version for this tutorial. Create a docker-compose.yml to install DynamoDB.

version: '3.8'
services…
Swathi Prasad

Software architect and developer living in Germany. Sharing my opinion and what I learn.