Basic Java Spring Boot Rest API implementation using MongoDB for data persistence.
- JDK 1.8
- Gradle 3.x
- MongoDB 3.x
- Clone the repository.
- Edit the application.properties file according to your environment parameters (example included).
- Open a terminal located in the root folder of the project.
- Build the project with the following command:
Unix based systems:
./gradlew clean build
Windows:
gradlew.bat clean build
- Run the service with the following command:
Unix based systems:
./gradlew bootRun
Windows:
gradlew.bat bootRun
- Or Run the service with the following command:
java -jar build/libs/movies-restapi-java-0.1.jar
- The service is up in: http://localhost:{port} ({port} is the port designed in the application.properties file)
This RestAPI has one basic endpoint that supports GET, POST, PUT and DELETE request methods.
-
GET all movies Request: Endpoint: http://localhost:{port}/api/v1/movies
-
GET movie by Id Request: Endpoint: http://localhost:{port}/api/v1/movies/{id}
-
POST movie Request: Endpoint: http://localhost:{port}/api/v1/movies
Request body example:
{
"title": "The Dark Knight",
"year": "2008",
"imDBScore": 9.0,
"synopsis": "When the menace known as the Joker emerges from his mysterious past, he wreaks havoc and chaos on the people of Gotham, the Dark Knight must accept one of the greatest psychological and physical tests of his ability to fight injustice."
}
Response body example:
{
"id": "59e80f23e9d7b50a54d127cf",
"title": "The Dark Knight",
"year": "2008",
"imDBScore": 9.0,
"synopsis": "When the menace known as the Joker emerges from his mysterious past, he wreaks havoc and chaos on the people of Gotham, the Dark Knight must accept one of the greatest psychological and physical tests of his ability to fight injustice."
}
- PUT movie Request: Endpoint: http://localhost:{port}/api/v1/movies/{id}
Request body example:
{
"title": "The Dark Knight",
"year": "2008",
"imDBScore": 9.5,
"synopsis": "When the menace known as the Joker emerges from his mysterious past."
}
Request body example:
{
"id": "59e80f23e9d7b50a54d127cf",
"title": "The Dark Knight",
"year": "2008",
"imDBScore": 9.5,
"synopsis": "When the menace known as the Joker emerges from his mysterious past."
}
- DELETE movie Request:
