A lightweight custom Spring Boot starter designed to automatically print environment variables at application startup — and optionally expose them via HTTP endpoint for easier debugging and configuration visibility.
This starter is useful for developers who deploy applications across multiple environments (like local, staging, or production) and need quick insight into what environment variables are available during runtime — without manually logging or debugging them.
- 🚀 Auto-prints environment variables at application startup with proper SLF4J logging
- 🌐 Actuator-independent HTTP endpoint at
/env/env-printer- no actuator dependency required - 🔍 Optional actuator endpoint at
/actuator/envprinterwhen actuator is present - 🎯 Smart project-only mode - scans configuration and optionally configured application packages
- 🚫 Hardcoded OS exclusions - automatically hides 50+ common OS-specific variables (APPDATA, TEMP, etc.)
- ⚙️ Highly configurable via
application.propertiesorapplication.yml - 📦 Zero configuration required - works out of the box with sensible defaults
- 🔤 Sorted output - environment variables are sorted alphabetically for easy reading
- 🎨 Spring Boot 3 compatible - uses modern autoconfiguration format
<dependency>
<groupId>io.github.skywalker690</groupId>
<artifactId>spring-boot-starter-env-printer</artifactId>
<version>2.1.0</version>
</dependency>Or from GitHub via JitPack:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Skywalker690</groupId>
<artifactId>spring-boot-starter-env-printer</artifactId>
<version>2.1.0</version>
</dependency>Environment variables will automatically be printed at startup (OS-specific variables excluded):
2025-10-28T14:00:07.184Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : ===============================
2025-10-28T14:00:07.184Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : 🌍 Environment Variables
2025-10-28T14:00:07.185Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : ===============================
2025-10-28T14:00:07.188Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : DATABASE_URL
2025-10-28T14:00:07.189Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : JAVA_HOME
2025-10-28T14:00:07.190Z INFO --- [main] com.skywalker.envprinter.EnvPrinter : SERVER_PORT
...
Endpoints are disabled by default. Set env.printer.endpoint-enabled=true to enable them, and protect them with authentication before exposing them.
# Actuator-independent endpoint (works without Spring Boot Actuator)
curl http://localhost:8080/env/env-printer
# Or if you have Spring Boot Actuator
curl http://localhost:8080/actuator/envprinterReturns:
{
"DATABASE_URL": "",
"JAVA_HOME": "",
"SERVER_PORT": ""
}# Enable or disable the env printer (default: true)
env.printer.enabled=true
# Enable or disable the HTTP endpoint (default: false)
env.printer.endpoint-enabled=trueProject-only mode shows only environment variables referenced in configuration files and, when enabled, configured application packages:
# Scan project files and show only used environment variables
env.printer.project-only=trueWhat does it scan?
application.propertiesandapplication.ymlfiles- Finds
${ENV_VAR}placeholders - Optionally detects
@Value("${ENV_VAR}")andSystem.getenv("ENV_VAR")in configured compiled application packages
Example:
If your application.yml contains:
database:
url: ${DATABASE_URL}
username: ${DB_USER}
server:
port: ${SERVER_PORT:8080}With project-only=true, only DATABASE_URL, DB_USER, and SERVER_PORT will be displayed (if they exist in the environment).
# Basic settings
env.printer.enabled=true
env.printer.endpoint-enabled=true
# Show only variables actually used in project
env.printer.project-only=true
# Show env values
env.printer.show-values=true
spring.application.name=my-spring-appYAML Configuration:
env:
printer:
enabled: true
endpoint-enabled: true
project-only: true
show-values: false
| Property | Type | Default | Description |
|---|---|---|---|
env.printer.enabled |
Boolean | true |
Enable/disable the environment printer. When disabled, no environment variables will be printed at startup and the endpoint will not be available. |
env.printer.endpoint-enabled |
Boolean | false |
Enable/disable the HTTP endpoints. Disabled by default to avoid exposing configuration metadata. |
env.printer.project-only |
Boolean | true |
Show only variables referenced in configuration files and optionally scanned compiled classes. |
env.printer.show-values |
Boolean | false |
Show values instead of names only. Values may contain secrets. |
env.printer.scan-compiled-classes |
Boolean | false |
Enable compiled-class scanning. Configure scan-packages when enabling. |
env.printer.scan-packages |
List | empty | Application package prefixes to scan, such as com.example.myapp. |
- Type: Standard REST endpoint
- Requires: Spring Web (no actuator needed)
- Access:
GET http://localhost:8080/env/env-printer - Response: JSON map of filtered environment variables
- Type: Spring Boot Actuator endpoint
- Requires: Spring Boot Actuator dependency
- Access:
GET http://localhost:8080/actuator/envprinter - Response: JSON map of filtered environment variables
- Note: Requires actuator endpoints to be exposed
- Java 17 or higher
- Spring Boot 3.2.4 or higher
- Spring Web (for REST controller endpoint)
- (Optional) Spring Boot Actuator for actuator endpoint
env.printer.project-only=trueAutomatically scans and shows only ${...} references from config files.
env.printer.project-only=falseShows all environment variables except OS-specific ones.
env.printer.enabled=falseenv.printer.enabled=true
env.printer.project-only=trueCheck logs to verify all required variables are set.
Be careful when exposing environment variables via HTTP endpoints in production. Consider:
The HTTP endpoint is disabled by default. If enabled, protect it with authentication and authorization; show-values=true can expose secrets.
- Using
project-only=trueto limit exposure - Securing endpoints with authentication
- Disabling in production with
env.printer.enabled=false - The starter automatically hides OS-specific variables
When project-only=true:
-
Scans configuration files in classpath:
application*.propertiesapplication*.yml,application*.yaml
-
Extracts variable references:
${VARIABLE_NAME}placeholders${VARIABLE_NAME:default}with defaults@Value("${VARIABLE_NAME}")annotationsSystem.getenv("VARIABLE_NAME")calls in configured compiled classes
-
Filters environment:
- Shows only variables found in step 2
- Excludes hardcoded OS variables
- Returns sorted alphabetically
Performance: Scanning happens once at startup and results are cached.
Compiled-class scanning is disabled by default. To enable it safely, configure narrow application packages:
env:
printer:
scan-compiled-classes: true
scan-packages:
- com.example.myappApache License 2.0
Author: Sanjo (Skywalker)
Repository: spring-boot-starter-env-printer