- with few basic CRUD REST APIs - Git Tag V1.1
- with Flyway integration for Database migration - Git Tag V2.0
- with Basic Authentication/Authorization - Git Tag V3.0
- with Hibernate Envers/JPA Auditing - Git Tag V4.0
- with Authentication using JWT - Git Tag V5.0
- with Caffeine Caching - Git Tag V6.0
- with Docker Compose - Git Tag V7.0
- with Distributed Cache using Hazelcast - Git Tag V8.0
For more detailed step by step guide on how to build this app, please refer to the blogs on - http://sunitc.dev/tag/spring-boot/
-
Pre-requisite (for first time run only)
Create a folder for mysql volume mount
mkdir -p ~/data/mysql8
-
Build
./gradlew clean build
-
Run via Docker Compose
docker-compose up -d --build --scale application=2
- Run SQL Script -
scripts/Create_Dummy_Data.sql
Username | Password | ROLE |
---|---|---|
[email protected] | admin01@123# | ADMIN |
[email protected] | admin02@123# | ADMIN |
[email protected] | welcome@123# | USER |
curl --location --request POST 'dev-sandbox/api/v1/auth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"userName": "[email protected]",
"password": "admin01@123#"
}'
curl --location --request GET 'dev-sandbox/api/v1/customer/?pageNum=0&pageSize=10' \
--header 'Authorization: Bearer <<REPLACE JWT TOKEN HERE>>'
In above code, replace the text <<REPLACE JWT TOKEN HERE>>
with JWT token from Auth API
- If after running Docker Compose, you are getting
404
on the APIs,- Restart ONLY the load-balancer container - sometimes this happens when loadbalancer starts before application server starts
- Create an alias for localhost (127.0.0.1)
- The reason for doing this is because we have configured the traefik loadbalancer using hostname
dev-sandbox
- So if you hit any api with host as
localhost
, it wont work with current configuration of traefik loadbalancer - Just open the following file
/etc/hosts
, and add following line at the end127.0.0.1 dev-sandbox
- After this configuration, restart the application using
docker-compose restart
- The reason for doing this is because we have configured the traefik loadbalancer using hostname
- Add a wait-for script in Docker compose for following container dependencies
- Loadbalancer - Depends on - Application
- Application - Depends on - Database