Getting Started
Purpose
MongoBank is a hands-on tutorial for developers that are wanting to get more comfortable with developing against the MongoDB database. Based on spring-boot and spring-data the work shops leads users through the process of creating a simulated banking app with customers, accounts, and transactions.
Getting Started
Assumptions:
- Java is installed on your system
- Docker is installed on your machine
- Maven or Gradle is installed on your machine
Setup Database
The system, when completed, is dependent on some features only available in MongoDB Atlas (Cloud Database as a Service). Fortunately we can use the Atlas Docker image to test our code for functionality in a local environment.
- Atlas
- Homebrew
- Windows
- Docker
You can also use a Free tier instances from MongoDB Atlas. To get started see MongoDB Atlas Free Tier
brew install mongodb-community
To install MongoDB Community on Windows follow these instructions MongoDB Community on Windows
For details on how to run MongoDB in docker, see this link. MongoDB Community with Docker
Full instructions on how to download and setup Atlas via docker are here Atlas on Docker
To complete the advanced topics you will need to use MongoDB Atlas. You can run Atlas via docker with the instructions found here Atlas in Docker
Download Code Repository
Clone this github repo to a location on your machine.
git clone xxxxxx
Update connection strings
Create a file named .env in the root of your project. Inside that file add the following entries
MONGODB_URI= <your connection string here>
Your connection string is going to be similar to
mongodb://localhost:27017. The specific port that shows will depend on the port mapptings you provided the Atlas docker container when you started it.
Build the application
Lets build the application to see that it run successfully. MongoBank is configured to work with both Gradle and Maven, so choose which every is comfortable or configured on your system.
- Maven
- Gradle
mvn spring-boot:run
./gradlew bootRun
Depending on the build tool you prefer to use.
Test that API calls work
The base system provides REST API endpoints, so lets verify that those are working and returning content.
curl locahost:8080/api/hello -H "Content-Type:application/json"
The response should look like
Hello World
If you get to this point you have everything ready to start the lab. Click on the link below for "Saving Objects" to start.