Git Product home page Git Product logo

spring-boot-with-dynamodb's Introduction

Spring Boot With Dynamo DB Example

This project shows how you can implement a Spring Boot API application that stores and reads data in a Dynamo DB with 2 tables (one table containing a list of other objects).

Project Information

Purpose

To be used as a stepping stone for other Spring Boot + Dynamo DB applications

Developer

DynamoDB Local

Download Local version
Install AWS CLI

Start Local Dynamo:
java -Djava.library.path=./dynamodb_local -jar ~/dev-tools/dynamodb_local/DynamoDBLocal.jar -sharedDb

Do:
aws configure AWS Access Key ID [None]: fakeMyKeyId AWS Secret Access Key [None]: fakeSecretAccessKey Default region name [None]: eu-west-01 Default output format [None]:

List tables available on DynamoDB:
aws dynamodb list-tables --endpoint-url http://localhost:8000

Dynamo UI:
npm install dynamodb-admin -g export DYNAMO_ENDPOINT=http://localhost:8000 dynamodb-admin

Browse to http://localhost:8001/

Running the app creates the tables for you. But, if you want to create Tables in Local DynamoDB (manually):

aws dynamodb create-table --table-name info --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000    
aws dynamodb create-table --table-name profile --attribute-definitions AttributeName=Id,AttributeType=S --key-schema AttributeName=Id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000

Delete Table from Local DynamoDB:

aws dynamodb delete-table --table-name info --endpoint-url http://localhost:8000
aws dynamodb delete-table --table-name profile --endpoint-url http://localhost:8000

Sample Request and Response

Create Content Request

POST http://localhost:9898/content

{
  "contents": [
    {
      "contentId": "83c1b410-ec14-4c2e-b165-afbf98f59627",
      "value": 0,
      "profileId": null,
      "description": "description",
      "placements": [
        {
          "features": "feature",
          "category": [
            "category1",
            "category2"
          ],
          "visible": true,
          "value": 100
        }
      ],
      "expirationDate": "2021-08-06 15:01:57"
    }
  ]
}
Response
[
  {
    "profile": {
      "id": "profile::45a496b4-69b8-4889-912d-f3ba474d0109",
      "description": "description",
      "mappings": [
        {
          "features": "feature",
          "category": [
            "category1",
            "category2"
          ],
          "visible": true,
          "value": 100
        }
      ],
      "lastUpdatedDate": "2021-08-31 14:22:40"
    },
    "info": {
      "id": "info::83c1b410-ec14-4c2e-b165-afbf98f59627",
      "value": 0,
      "profileId": "profile::45a496b4-69b8-4889-912d-f3ba474d0109",
      "expirationDate": "2021-08-06 15:01:57",
      "lastUpdatedDate": "2021-08-31 14:22:40"
    }
  }
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.