This is a sample multi module maven project which conatins a set of Restful API operations on Product. The project caters a variety of CRUD operations on product/product options.
This is a multi module maven project. This project is compiled in Java 8 with Spring Boot following microservice pattern. The Project has three modules:
- The
micoservice
module produces a spring boot application. - The
functional-tests
is used to run functional tests using the karate library. - The
docker
module is used to package the microservice artefact into a docker image and push it onto a docker registry.
Basic Prerequisite :
- Maven Setup
- Open JDK 8 or Oracle Java 8
Running in local:
-
Once you have the above Prerequisites, compile the project code and run the below command. This would run the entire build for all modules and execute tests with creating artefacts.
mvn clean install
-
You could also run only the application by using below command :
mvn spring-boot:run
The project also uses JaCoCo which is a free code coverage library for Java.
Once the tests are executed(using mvn clean install
) the code coverage report is generated in
below locations.
-
Jacoco data file location -
functional-tests/target/jacoco-merged.exec
-
Jacoco Coverage Report location -
functional-tests/target/jacoco-report/index.html
The Project uses Google Java Code Style.
- http://localhost:8080/v2/api-docs
- http://localhost:8080/swagger-ui.html
- The API documentation makes use of Springfox OpenAPI swagger libraries.
GET /products
- Gets all products.GET /products?name={name}
- Finds all products matching the specified name.GET /products/{id}
- Gets the project that matches the specified ID - ID is a UUID.POST /products
- Creates a new product.PUT /products/{id}
- Updates a product.DELETE /products/{id}
- Deletes a product and its options.GET /products/{id}/options
- Finds all options for a specified product.GET /products/{id}/options/{optionId}
- Finds the specified product option for the specified product - optionId is a UUID.POST /products/{id}/options
- Adds a new product option to the specified product.PUT /products/{id}/options/{optionId}
- Updates the specified product option.DELETE /products/{id}/options/{optionId}
- Deletes the specified product option.
To create a docker image from this artefact add the pom profile build-docker-image
and a docker image will get created in your registry. Command as follows :
mvn clean install -P build-docker-image