com.github.elvisnovoa:dynamodb-spring-boot-parent

Spring Boot starter project for spring-data-dynamodb

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.github.elvisnovoa
ArtifactId

ArtifactId

dynamodb-spring-boot-parent
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

com.github.elvisnovoa:dynamodb-spring-boot-parent
Spring Boot starter project for spring-data-dynamodb
Project URL

Project URL

https://github.com/elvisnovoa/dynamodb-spring-boot
Source Code Management

Source Code Management

http://github.com/elvisnovoa/dynamodb-spring-boot/tree/main

Download dynamodb-spring-boot-parent

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.elvisnovoa/dynamodb-spring-boot-parent/ -->
<dependency>
    <groupId>com.github.elvisnovoa</groupId>
    <artifactId>dynamodb-spring-boot-parent</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.elvisnovoa/dynamodb-spring-boot-parent/
implementation 'com.github.elvisnovoa:dynamodb-spring-boot-parent:1.0.0'
// https://jarcasting.com/artifacts/com.github.elvisnovoa/dynamodb-spring-boot-parent/
implementation ("com.github.elvisnovoa:dynamodb-spring-boot-parent:1.0.0")
'com.github.elvisnovoa:dynamodb-spring-boot-parent:pom:1.0.0'
<dependency org="com.github.elvisnovoa" name="dynamodb-spring-boot-parent" rev="1.0.0">
  <artifact name="dynamodb-spring-boot-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.elvisnovoa', module='dynamodb-spring-boot-parent', version='1.0.0')
)
libraryDependencies += "com.github.elvisnovoa" % "dynamodb-spring-boot-parent" % "1.0.0"
[com.github.elvisnovoa/dynamodb-spring-boot-parent "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter jar 2.4.1

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.4.1

Project Modules

  • dynamodb-spring-boot-autoconfigure
  • dynamodb-spring-boot-starter
  • dynamodb-spring-boot-sample-app

dynamodb-spring-boot

A simple wrapper for derjust's Spring Data DynamoDB.

Usage:

Add the dependency to your pom.xml

        <dependency>
            <groupId>com.github.elvisnovoa</groupId>
            <artifactId>dynamodb-spring-boot-starter</artifactId>
            <version>1.0.0</version>
        </dependency>

Then follow derjust's instructions to set up your repositories. For example, given a DynamoDB table named User, we have the corresponding POJO:

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

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

    public User() {}

    public User(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    @DynamoDBHashKey
    @DynamoDBAutoGeneratedKey
    public String getId() {
        return id;
    }

    @DynamoDBAttribute
    public String getFirstName() {
        return firstName;
    }

    @DynamoDBAttribute
    public String getLastName() {
        return lastName;
    }
    
    // setters omitted
}

...and the following Spring Data Repository.

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

Customizing

This autoconfigure project uses the default spring-data-dynamodb configurations and reads any repositories in the same package of a @SpringBootApplication. To use different configurations, you can create your own configuration class and annotate it with @EnableDynamoDBRepositories. In that case, why are you using this?

The library also creates a com.amazonaws.services.dynamodbv2.AmazonDynamoDB bean with default configurations, but you can provide your own. For example:

    private AWSCredentialsProvider amazonAWSCredentialsProvider() {
        return new AWSStaticCredentialsProvider(amazonAWSCredentials());
    }

    private AWSCredentials amazonAWSCredentials() {
        return new BasicAWSCredentials("amazonAWSAccessKey", "amazonAWSSecretKey"); // Don't ever do this, plz
    }

    @Bean
    public AmazonDynamoDB amazonDynamoDB() {
        return AmazonDynamoDBClientBuilder.standard()
                .withCredentials(amazonAWSCredentialsProvider())
                .build();
    }

Versions

Version
1.0.0