Simplifies the development of creating an Amazon DynamoDB-based Java data access layer
Latest commit f35faa2 Jan 31, 2016 @michaellavelle Update

Spring Data DynamoDB

Due to external time and project commitments, I'm no longer able to continue active development of this project as of January 2016. Thank you to everyone involved in shaping the project over the past few years and thanks to all those who have raised issues and submitted pull requests over the time.

@derjust has kindly offered to continue managing the progression of spring-data-dynamodb going forward - the latest version of the project can be found at the following fork:

Thank you Sebastian for your help with the project to date and for this kind offer.

Kind Regards,


The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use data access technologies. This module deals with enhanced support for Amazon DynamoDB based data access layers.

Supported Features

  • Implementation of CRUD methods for DynamoDB Entities
  • Dynamic query generation from query method names (Only a limited number of keywords and comparison operators currently supported)
  • Possibility to integrate custom repository code
  • Easy Spring annotation based integration

Demo application

For a demo of spring-data-dynamodb, using spring-data-rest to showcase DynamoDB repositories exposed with REST, please see spring-data-dynamodb-demo


The major and minor number of this library refers to the compatible Spring framework compatibility: 4.2.n is compatible with Spring framework 4.2.0.

Quick Start

Download the jar though Maven:


Setup DynamoDB configuration as well as enabling Spring Data DynamoDB repository support.

@EnableDynamoDBRepositories(basePackages = "com.acme.repositories")
public class DynamoDBConfig {

    private String amazonDynamoDBEndpoint;

    private String amazonAWSAccessKey;

    private String amazonAWSSecretKey;

    public AmazonDynamoDB amazonDynamoDB() {
        AmazonDynamoDB amazonDynamoDB = new AmazonDynamoDBClient(
        if (StringUtils.isNotEmpty(amazonDynamoDBEndpoint)) {
        return amazonDynamoDB;

    public AWSCredentials amazonAWSCredentials() {
        return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);


or in xml...

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

  <bean id="amazonDynamoDB" class="">
    <constructor-arg ref="amazonAWSCredentials" />
    <property name="endpoint" value="${amazon.dynamodb.endpoint}" />

  <bean id="amazonAWSCredentials" class="com.amazonaws.auth.BasicAWSCredentials">
    <constructor-arg value="${}" />
    <constructor-arg value="${}" />

  <dynamodb:repositories base-package="com.acme.repositories" amazon-dynamodb-ref="amazonDynamoDB" />


Create a DynamoDB hash-key only table in AWS console, with table name 'User' and with hash key attribute name "id"

Create a DynamoDB entity for this table:

@DynamoDBTable(tableName = "User")
public class User {

  private String id;
  private String firstName;
  private String lastName;

  public String getId()
    return id;

  public String getFirstName()
    return firstName;

  public String getLastName()
    return lastName;

  // setters, default constructor and firstname/lastname constructor

Create a CRUD repository interface in com.acme.repositories:

public interface UserRepository extends CrudRepository<User, String> {
  List<User> findByLastName(String lastName);

or for paging and sorting...

public interface UserRepository extends PagingAndSortingRepository<User, String> {
  Page<User> findByLastName(String lastName,Pageable pageable);

  public Page<User> findAll(Pageable pageable);

Write a test client

public class UserRepositoryIntegrationTest {

  @Autowired UserRepository repository;

  public void sampleTestCase() {
    User dave = new User("Dave", "Matthews");;

    User carter = new User("Carter", "Beauford");;

    List<User> result = repository.findByLastName("Matthews");
    assertThat(result.size(), is(1));
    assertThat(result, hasItem(dave));