ecommercemicroservice
eCommerce
CSS
This is a microservices demo project, please follow below steps to access them. If you use docker, please see the “ReadyMe for Docker” section.
- make sure you have MySql and Redis installed
- build the projects by command “mvn clean package”
- start by right click the Application.java and select run as java application
- check the application.yml and prepare database account
- run data.sql that in the project’s resources folder if needs
- start those common microservice follow this order: Eureka, Zuul, Auth
- start business microservice like Product service and check API from Swagger localhost:8102/swagger-ui.html
- those API needs Oauth Token to access, current solution support Client Credentials and Resource Owner Password Credentials, details in following steps
- 密码模式get token
- 客户端模式 get token
- use token
- login endpoint
Note that: refresh token for 密码模式还有bug,暂时用不了
ReadyMe for Docker
Precondition: Install docker and docker compose in your local
Start a specific microservice
open terminal(cmd), navigate to the related folder and run below commands:
Take microservice.product.service as example:
build image
cd microservice.product.service
mvnw package dockerfile:build
start service
docker-compose up -d
Then access http://localhost:8002/product/1 to see the result
You can stop the service via command – docker-compose down
Start all the microservices
- Go to each microservice, and run mvnw package dockerfile:build
- Go back to parent folder ecommercemicroservice, then type command – docker-compose up -d
- Check the registered service on Eureka via http://localhost:8761