Spring Boot Application Template
APACHE-2.0 License
This repository is a template for creating a Spring Boot application with commonly used features pre-configured.
Install Java using SDKMAN
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk version
$ sdk env install
Install Docker : https://docs.docker.com/get-docker/
$ 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
.
This section describes how to perform various tasks.
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
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
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
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
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
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/