spring-boot-application-template

Spring Boot Application Template

APACHE-2.0 License

Stars
31

Spring Boot Application Template

This repository is a template for creating a Spring Boot application with commonly used features pre-configured.

Features

  • Spring Boot
  • Spring Data JPA
  • PostgreSQL
  • Flyway for DB migration
  • Springdoc Open API
  • JaCoCo code coverage check
  • SonarQube code quality check
  • OWASP Dependency Check
  • JUnit 5
  • Testcontainers for testing & Local Dev
  • GitHub Actions
  • DockerCompose Deployment

Prerequisites

Getting Started

$ git clone https://github.com/sivaprasadreddy/spring-boot-application-template.git
$ cd spring-boot-application-template
$ ./gradlew build

To run the application from IDE, run TestApplication.java under src/test/java.

How to?

This section describes how to perform various tasks.

Code Formatting

The Spotless for Gradle combined with palantir-java-format is used to format source code and is configured to automatically check code formatting while building the application.

$ ./gradlew spotlessApply    <- to format source code
$ ./gradlew spotlessCheck    <- to verify source code formatting

JaCoCo Code Coverage

The The JaCoCo Plugin is used to verify the test code coverage. If the expected code coverage is not met (default is set to 80%) then the build will fail.

$ ./gradlew jacocoTestCoverageVerification

SonarQube Quality Check

The Gradle SonarQube Plugin is configured and is configured to run on SonarCloud.

You can configure the sonar properties in sonar-project.properties and run the sonar scan as follows:

$ ./gradlew sonarqube -Dsonar.login=$SONAR_TOKEN

OWASP Dependency Check

The OWASP dependency-check-gradle plugin is used to check for security vulnerabilities in the used libraries.

$ ./gradlew dependencyCheckAnalyze

You can see the generated report at target/dependency-check-report.html

Create Docker Image

The spring-boot-gradle-plugin provides the capability to create an OCI image from a jar or war file using Cloud Native Buildpacks (CNB).

$ ./gradlew bootBuildImage --imageName=$DOCKER_USERNAME/$DOCKER_IMAGE_NAME

Run application using docker-compose

Once the application docker image is created, you can run the application using docker-compose as follows:

$ cd deployment/docker-compose
$ docker compose up -d

Now the application should be accessible at http://localhost:8080/

Badges
Extracted from project README
Maven Build Gradle Build Quality Gate Status