Spring Boot · Lesson 7 of 7

Profiles, Actuator & deployment

Environment profiles, health checks with Actuator, building a JAR and running in Docker.

Before going live, an app needs environment-specific config, health checks and a repeatable build.

  • Profiles: application-dev.yml and application-prod.yml, chosen with SPRING_PROFILES_ACTIVE=prod.
  • Secrets come from environment variables or a secrets manager — never commit them.
  • Actuator adds endpoints such as /actuator/health for load balancers and Kubernetes probes, and metrics for monitoring. Expose only what you need.
  • Build a runnable JAR with ./mvnw clean package, then run java -jar target/app.jar.
  • Docker: copy the JAR into a small Java runtime image.

Example code

Spring Boot 3 · Java 17+
# application-prod.yml
spring:
  datasource:
    url: jdbc:postgresql://db:5432/jobs
    username: app
    password: ${DB_PASSWORD}
management:
  endpoints:
    web:
      exposure:
        include: health,info

# Dockerfile
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY target/jobs-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

# terminal
$ ./mvnw clean package
$ docker build -t jobs-api .
$ docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod -e DB_PASSWORD=*** jobs-api

Output / API response

[INFO] BUILD SUCCESS
Successfully tagged jobs-api:latest
The following 1 profile is active: "prod"
Tomcat started on port 8080 (http)

$ curl localhost:8080/actuator/health
{"status":"UP"}

Generate a project at start.spring.io (Maven, Java 17+, dependencies: Spring Web, Spring Data JPA, H2, Validation), add the code, and run ./mvnw spring-boot:run. Learn the Java tutorial first if you're new to Java. Data is fictional.

Key points

  • Use profiles for dev/test/prod settings.
  • Read secrets from environment variables.
  • Actuator health endpoints feed load balancers and probes.
  • Package as a JAR and run it in a slim Docker image.

Quick check

Which Actuator endpoint do load balancers usually call?

Practice task

Add a dev profile that uses H2 and a prod profile that uses PostgreSQL, then run the app with each profile and check /actuator/health.

Interview corner

How do you manage configuration for different environments?

Use Spring profiles with application-{profile}.yml files, activate one with SPRING_PROFILES_ACTIVE, and inject secrets via environment variables or a vault, so the same JAR runs in every environment.

What is Spring Boot Actuator?

A module that adds production endpoints: health checks, metrics, info, environment and more. They're used for monitoring and orchestration; sensitive endpoints should be secured or left unexposed.

Further reading

Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.

Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.