This is a sample Java project that demonstrates how to use DynamoDB Local for local development and testing. DynamoDB Local is a downloadable version of DynamoDB that enables you to develop and test applications without connecting to the actual DynamoDB service provided by AWS. This project showcases multiple approaches to set up and use DynamoDB Local, including downloading JAR files, running it as a Docker image, and using it as a Maven dependency.
- Java Development Kit (JDK) 11 or later installed on your system
- Apache Maven installed on your system
- Docker installed (if running DynamoDB Local as a Docker image)
- Clone this repository to your local machine.
- Ensure that you have the prerequisites mentioned above installed.
- Open a terminal or command prompt and navigate to the project's root directory.
If you prefer to download and run DynamoDB Local as JAR files, follow these steps:
- Download the DynamoDB Local JAR files from the AWS website:
- Place the downloaded JAR files in a directory of your choice.
- Open a terminal or command prompt and navigate to the directory where you placed the JAR files.
- Run the following command to start DynamoDB Local:
The
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
-sharedDb
flag indicates that DynamoDB Local will use a single database file for all data and will persist between restarts.
If you prefer to use DynamoDB Local as a Docker image, follow these steps:
- Make sure Docker is running on your system.
- Open a terminal or command prompt.
- Run the following command to pull the DynamoDB Local Docker image:
docker pull amazon/dynamodb-local
- Once the image is downloaded, run the following command to start DynamoDB Local as a Docker container:
docker run -p 8000:8000 amazon/dynamodb-local
If you prefer to use DynamoDB Local as a Maven dependency, follow these steps:
- Open the
pom.xml
file in your project. - Add the following dependency to the
<dependencies>
section:<dependency> <groupId>com.amazonaws</groupId> <artifactId>DynamoDBLocal</artifactId> <version><LATEST_VERSION></version> </dependency>
You can find the latest version of DynamoDB Local here: https://mvnrepository.com/artifact/com.amazonaws/DynamoDBLocal
- Build your project using Maven:
mvn clean package
Optional: Create a a runnable jar: https://www.baeldung.com/executable-jar-with-maven
See CONTRIBUTING for more information.
To report a bug or request a feature or to contact the DynamoDB Local team, reach out to us at aws-ddblocal-feedback@amazon.com.
This library is licensed under the MIT-0 License. See the LICENSE file.