Skip to content

Welcome to the Spring Practices Demo – a powerful Spring Boot application designed to support data JPA, pageable, and sorting with an intuitive Swagger interface. Explore and learn best practices in Java development, including efficient techniques with MapStruct, seamless database migration using Flyway, and more.

License

Notifications You must be signed in to change notification settings

alvelchev/spring-practices-demo

Repository files navigation

Please ⭐ this repository if you find it useful. Thank you.

Spring Practices Demo

Spring Docker Image CI codecov License: MIT

Integration with GitHub Actions

Table of Contents

Introduction

Welcome to the Spring Boot Best Practices Application! This project serves as a comprehensive demonstration of fundamental Java Spring concepts, highlighting industry best practices and essential techniques for building robust Spring Boot applications. The project is designed to be a reference for developers of all levels, providing examples of a wide range of Spring Boot features and implementations.

Key Features and Demonstrations

  • Model-View-Controller (MVC) Architecture: Embracing the MVC pattern for a well-organized and modular structure.
  • MapStruct for Object Mapping: Streamlining object mapping for enhanced readability and maintainability.
  • Flyway for Database Migration: Seamless database migration management through Flyway.
  • JUnit 5 Configuration: Configured JUnit 5 for effective testing and robust code coverage.
  • JSON Data Processing: Efficiently reading and filtering data from JSON files.
  • Basic CRUD Operations: Implementation of essential CRUD operations for effective resource management.
  • Pageable Response Handling: Demonstrating easy filtering, sorting, and more with Pageable responses.
  • Global Exception Handling: A global exception handler for managing exceptions across the codebase.
  • Custom Spring Validator: Examples of custom Spring validators at field and class levels.
  • CriteriaBuilder for Data Retrieval: Using CriteriaBuilder for advanced data retrieval.
  • Spring Boot Actuator: Configuring Spring Boot Actuator for collecting application metrics.
  • Git Information Injection: Injecting Git information into Spring for version tracking.
  • Quartz Scheduler: Implementation of Quartz scheduler using Cron Triggers and Expressions.
  • Spring Custom Events: Leveraging Spring Custom Events for event-driven architecture.

GitHub Actions Pipelines Integration

  • Integrated with GitHub Actions for code analyses with SonarCloud and Codecov for code coverage reports.
  • Integrated with Docker. On every push event to the main branch, a new Docker image is generated.
  • Integrated with Maven Dependency tree generation.

SonarCloud:

Codecov:

How to Start the Project

  1. Clone the repository.
  2. Start the local PostgreSQL.
  3. Run Maven clean install.
  4. Open the Swagger URL to test the endpoints: Swagger UI
  5. Open Spring Boot Actuator endpoint: Actuator

Provided Examples with Implementation on Spring Boot

Branches:

  • Branch with name: "java11Version" is set up for JDK11
  • Main branch is with the newest spring boot 3.0.2 and JDK17

Git commit plugin response:

// 20221101225521
// http://localhost:8099/actuator/info

{
  "git": {
    "commit": {
      "message": {
        "short": "Merge branch 'main' into gitCommitPlugin"
      },
      "id": {
        "abbrev": "34078b6",
        "full": "34078b613c32ac9cf4f076b42232e3d9523aaeb7",
        "describe": "34078b6-dirty"
      },
      "time": "2022-11-01T18:59:21Z",
      "history": "https://github.com/alvelchev/spring-practices-demo/commit/4b36876"
    },
    "branch": "gitCommitPlugin",
    "build": {
      "time": "2022-11-01T20:53:58Z",
      "version": "0.0.1"
    }
  },
  "build": {
    "artifact": "springpageable",
    "name": "springpageable",
    "time": "2022-11-01T20:53:56.838Z",
    "version": "0.0.1",
    "group": "com.springpracticesdemo"
  }
}

About

Welcome to the Spring Practices Demo – a powerful Spring Boot application designed to support data JPA, pageable, and sorting with an intuitive Swagger interface. Explore and learn best practices in Java development, including efficient techniques with MapStruct, seamless database migration using Flyway, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages