Giter VIP home page Giter VIP logo

ryzanugrah / spring-boot-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chatterjeesunit/spring-boot-app

0.0 0.0 0.0 112 KB

Spring Boot application with - Flyway migration, JWT authentication, Hibernate Envers Auditing, Hazelcast distributed caching, Docker Compose support. Checkout different releases for all features added to this application - https://github.com/chatterjeesunit/spring-boot-app/releases

Home Page: http://sunitc.dev/tag/spring-boot/

Java 100.00%

spring-boot-app's Introduction

Sample Spring Boot project

Releases

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/

How to run it

  • 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

Creating Dummy Data

  • Run SQL Script - scripts/Create_Dummy_Data.sql

Default Users for Login

Username Password ROLE
[email protected] admin01@123# ADMIN
[email protected] admin02@123# ADMIN
[email protected] welcome@123# USER

Sample APIS

1. API to get JWT Auth Token
curl --location --request POST 'dev-sandbox/api/v1/auth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "userName": "[email protected]",
    "password": "admin01@123#"
}'
2. API to get all customers (paginated)
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

Troubleshooting

  • 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 end
        127.0.0.1 dev-sandbox
      • After this configuration, restart the application using
        docker-compose restart

To-Do

  • Add a wait-for script in Docker compose for following container dependencies
    • Loadbalancer - Depends on - Application
    • Application - Depends on - Database

spring-boot-app's People

Contributors

chatterjeesunit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.