Code Monkey home page Code Monkey logo

alvelchev / spring-practices-demo Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 6.0 469 KB

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: MIT License

Java 99.74% Dockerfile 0.10% Shell 0.16%
java java11-spring-boot mapstruct mapstruct-example postgresql swagger-api swagger-ui junit-test junit5 exception-handler exception-handling github-actions sonarcloud criteriabuilder quartz-scheduler spring-events

spring-practices-demo's Introduction

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"
  }
}

spring-practices-demo's People

Contributors

alvelchev avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spring-practices-demo's Issues

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.