Building Spring Boot Apps and CI Tips

Harry · 14 Sep 2026 · 3 views
Advertisement
Advertisement

Packaging a Spring Boot app

Spring Boot’s build plugin repackages your JAR/WAR into an executable “fat jar” that contains your code, all dependencies and an embedded server – you run it with plain java -jar, no external Tomcat required:

./mvnw clean package
java -jar target/shop-1.0.0.jar
# Gradle equivalent:
./gradlew bootJar
java -jar build/libs/shop-1.0.0.jar

Run and test during development

./mvnw spring-boot:run      # run without packaging
./gradlew bootRun

Build practices for CI

  • Use the wrapper so CI builds with the exact tool version you do.
  • Cache dependencies – have CI cache ~/.m2 / ~/.gradle so builds do not re-download the internet every run.
  • Run tests in CI, not around itmvn verify compiles, tests and runs integration checks; fail the pipeline if anything breaks.
  • Pin versions – avoid version ranges so a build is reproducible months later.
  • Keep builds fast – Gradle’s build cache and Maven’s parallel builds (-T 1C) cut CI time.

A typical CI pipeline

1. checkout code
2. restore dependency cache
3. ./mvnw -B clean verify      # build + test (batch mode)
4. build a Docker image from the jar
5. push the image and deploy

-B (batch mode) gives clean, non-interactive logs suited to CI.

Key points

  • The Spring Boot plugin builds an executable fat jar you run with java -jar.
  • Use spring-boot:run / bootRun for quick local runs.
  • In CI, use the wrapper, cache dependencies, and run verify to gate on tests.
  • Pin versions and use caching/parallelism for reproducible, fast builds.
Share this post:

Comments (0)

Please login or register to comment.