Energy Consumption API project consists a couple of the endpoints like GET /consumption, and POST /event and GET /microgeneration for a technical test using Java Technology with Spring Boot, RESTFUL, build in Gradle and persistence by MongoDB.
Requirements:
-
Have the MongoDB database installed on the local machine or server:
Note: Keep MongoDB Compass installation enabled.
-
Access the database
-
Create energy database if necessary.
-
Having Java 8 or higher installed on your computer or laptop:
-
Clone the project by running the command in a folder of your choice:
git clone https://github.com/jamilsolutions/energy.git
-
Enter the directory where the project was cloned and open a command prompt with Git Bash:
Note: 1. If you do not have git installed use this link to install:
- https://git-scm.com/downloads
- Git Tutorial at https://git-scm.com/book/pt-br/v2
-
Edit the /energy/src/main/resources/application.yml file with the database settings:
Example:
spring: data: mongodb: host: localhost port: 27017 database: energy
- Run the command in the project /energy with the command:
./gradlew bootJar
- Run the project with the command
cd /build/libs/
java -jar energy-0.0.1-SNAPSHOT.jar
- Open Postman and import the Secure collection Energy.postman_collection.json:
Postman -> File -> Import -> Select folder or Upload the file -> Confirm import.
- Run the collection Energy:
Run Collection Runner -> Run Energy.
- Completed. Great job!