Spring Boot with MongoDB integration
- Import the project into Eclipse as Maven project
- Read MongoDB setup described below
- Find
Application.java
from side bar, right click on the file, select 'Run As' > 'Java Application' from menu. - Make a POST request to http://localhost:8080/users with the payload:
{"firstname":"Ben","lastname":"Linus","items":[{"itemName":"iPhone","quantity":1},{"itemName":"Apple","quantity":3}]}
- Make a GET request to http://localhost:8080/users
- There are more endpoints. For details, check
UserController.java
- Open Terminal or Command Prompt
- Run MongoDB:
$ mongod --dbpath /YOUR/MONGODB/STORE/DIRECTORY
- On Eclipse, check the configuration file,
Beans.java
to point to your MongoDB