Skip to content

mmushfiq/springboot-microservice-template

Repository files navigation

Spring Boot Microservice Template

Spring Boot JDK Docker Compose PostgreSQL MongoDB Redis RabbitMQ OpenTelemetry JUnit 5 ArchUnit GitHub

This is a template Spring Boot microservice implemented using Spring Boot 3.3 and Java 21. It demonstrates the integration of various technologies and best practices for building microservices. Additionally, it showcases the usage of the Common Library.

{PN} - project name or project name abbreviation

Note: This repository does not represent real-world business scenarios; the examples are solely intended to demonstrate the usage of various technologies.

Technologies and Tools Used

This template integrates multiple tools and frameworks, including:

  • Docker Compose - For containerized dependencies.
  • PostgreSQL - Relational database.
  • Liquibase - Database migration tool for PostgreSQL.
  • MongoDB - NoSQL database.
  • Mongock - Database migration tool for MongoDB.
  • Redis - In-memory caching system.
  • RabbitMQ - Message broker for event-driven communication.
  • ShedLock - Ensures scheduled tasks run in distributed environments.
  • Logstash/Logback - Centralized logging.
  • Checkstyle - Code style enforcement.
  • OpenFeign - Declarative REST client.
  • OpenTelemetry - Observability and distributed tracing.
  • JUnit 5 - Unit testing framework.
  • ArchUnit - Architecture rule validation.

Running the Application Locally

Prerequisites

  • Java 21
  • Gradle
  • Docker & Docker Compose

Start Dependencies

Before running the application, start required dependencies using Docker Compose:

docker-compose up

This will create PostgreSQL, MongoDB, Redis, RabbitMQ, and Jaeger containers.

Setting Up the Common Library Dependency

The springboot-microservice-common-lib dependency is not yet available in a central repository. To use it, you need to pull it from the GitHub package repository, which requires a GPR_TOKEN. Since this token is private and user-specific, it cannot be shared in this repository.

To include the dependency locally, follow these steps:

  1. Clone the springboot-microservice-common-lib repository:
    git clone https://github.com/mmushfiq/springboot-microservice-common-lib.git
  2. Navigate to the cloned directory:
    cd springboot-microservice-common-lib
  3. Publish the library to your local Maven repository using Gradle:
    ./gradlew publishToMavenLocal

After completing these steps, the dependency will be available in your local Maven repository and can be used by this microservice.

Running the Application

Run the application with the local profile. You can do this via IntelliJ IDEA run configurations or using the Gradle command:

./gradlew bootRun --args='--spring.profiles.active=local'

API Documentation

Swagger UI is available at:

http://localhost:8080/swagger-ui.html

Additional Tools

License

This project is licensed under the Apache-2.0 License.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •