A Example RESTful web service for managing packages consisting of one or more products. Microservice makes use of an online product service to get products.
Check shop-ui repo for basic UI which consumes Shop service rest APIs.
Service uses Java - Spring ecosystem
You need to have Docker installed
Following command will pull and run the image on machine. This will run shop service with default configuration
docker run -p 8080:8080 arpanps/microservice-shop:0.0.1-SNAPSHOT
The API documentations will be available at the path /api-docs
http://localhost:8080/shop/api-docs/
Interact with application API specification and exercise the endpoints via Swagger UI. Access Swagger UI using below link
http://localhost:8080/shop/swagger-ui/index.html?url=/shop/api-docs
-
Prerequisite - git, java, maven
-
Clone Repo
git clone https://github.com/arpanps/shop.git
-
Go inside project directory
cd shop
-
Build Project with Maven
mvn install
-
Run Service using Maven
mvn spring-boot:run
-
Package project
mvn clean package
-
Build the docker image (Use your username instead of arpanps)
docker build -t arpanps/microservice-shop -f etc/docker/Dockerfile .
-
Login with your Docker Id
docker login
-
Tag the image
docker tag arpanps/microservice-shop arpanps/microservice-shop:0.0.1-SNAPSHOT
-
Push the image to docker hub
docker push arpanps/microservice-shop:0.0.1-SNAPSHOT
-
OpenAPI - OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API
-
Swagger UI - Swagger UI allows anyone — be it development team or end consumers — to visualize and interact with the API’s resources without having any of the implementation logic in place.
-
Spring Boot - Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications.
-
Apache Derby - Currently service uses derby, embedded database, for package storage. Derby is very helpful during the development phase, because they are lightweight, fast, quick start time, improve testability, ease of configuration, it lets developer focus more on the development.
-
Hibernate - Hibernate is the most popular ORM framework
-
Actuator - Actuator includes a number of additional features to help you monitor and manage your application when it’s pushed to production, including useful metric, dump and health endpoints.
-
Docker - Docker is a tool designed to make it easier to create, deploy, and run applications by using containers
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Spring Boot DevTools
- Spring Boot Actuator
- Spring Data JPA
- Spring Web
The following guides illustrate how to use some features concretely: