Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Spring Boot environment binding: prove the value in a child JVM

Last updated: 30 Sept 20264 min read
tutorial
IntermediateBy AITrove Editorial

Spring Boot binds RELAY_BATCHSIZE and RELAY_TIMEOUT from the environment inherited by a launched JVM.

Download Spring source kit

The process boundary

RelaySettingsProcessTest launches a separate non-web Boot process with RELAY_BATCHSIZE=29 and RELAY_TIMEOUT=750ms. Its output reports batch 29 and timeout 750 milliseconds. That check crosses the operating-system process boundary; injecting a MapPropertySource into the parent test would not. The canonical naming rule maps relay.batch-size to RELAY_BATCHSIZE, with the dash removed.

The test clears inherited relay variables before assigning its own. Otherwise a developer shell or CI setting could change the assertion. The child uses bounded defaults of batch 8 and two seconds so the test can distinguish an absent key from an applied override. A deployment should still validate that each required key is present; a plausible default can hide a misspelling.

Where the check stops

This child is a small probe, not ReceiptApplication. It checks two plain values and bean validation under one pinned Boot baseline. It does not read a mounted secret, start the HTTP service or verify a container entrypoint. The process-test boundary separates these claims.

Keep credentials out of diagnostic output. The probe prints non-secret values only. A production startup log can report whether a secret source was found without printing the secret itself.

Checked source

bash
RELAY_BATCHSIZE=29 RELAY_TIMEOUT=750ms java -cp "$CLASSPATH" in.aitrove.contracts.RelaySettingsProcessProbe
# BOUND_BATCH=29
# BOUND_TIMEOUT=750

Verification boundary

RelaySettingsProcessTest.actualEnvironmentBindsTheCanonicalRelayKeys. The source kit contains the full test and entry point.

Common Mistakes

  • Do not use RELAY_BATCH_SIZE for relay.batch-size without checking the actual binding rule.
  • Do not pass the same value as a command-line flag and call that an environment test.
  • Do not print secret values to prove that binding worked.

Read next

Spring Boot environment variables: bind the intended key, not a lookalike, Spring Boot config precedence: command line beats a process variable, Spring Boot environment validation: fail before a worker starts, Spring Boot config tests: what a child JVM proves and what deployment still owes.

spring
configuration
testing
Storage details