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

Spring Boot configtree versus environment: assert the effective value

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

The checked process takes relay.batch-size from its environment when a configtree also provides that property.

Download Spring source kit

Create a real collision

A local file tree contains relay/batch-size with 41. The child process inherits RELAY_BATCHSIZE=44. It reports BOUND_BATCH=44, establishing the effective bean value under this pinned Boot configuration. This complements the environment-versus-CLI test and the file-versus-CLI test. One source list alone would not show which value the worker receives.

Operationally, the operator may mount 41 while a launcher injects 44. Inspect the final process environment and non-secret bound value when diagnosing a surprise batch size. The polling budget determines the work admitted per tick.

Avoid a blanket precedence slogan

This fixture has one tree, one environment value and one programmatic default. Profile files, Java system properties, JSON application properties and test-only sources are absent. The matrix keeps combinations distinct. Do not extrapolate this assertion to every source type.

Credentials require a different diagnostic. It is enough to verify their source and shape without printing their values.

Checked source

Output
// mounted-values/relay/batch-size: 41
// child environment: RELAY_BATCHSIZE=44
// child result: BOUND_BATCH=44

Verification boundary

RelaySettingsProcessTest.environmentValueOverridesTheImportedFileTree. The full fixture is in the downloadable source kit.

Common Mistakes

  • Do not inspect only the mounted file when an environment override exists.
  • Do not print secret values while tracing source precedence.
  • Do not claim this pairwise test covers every Boot property source.

Read next

Spring Boot configtree: bind one file per property in a child JVM, Spring Boot config precedence: command line beats a process variable, Spring Boot configuration sources: test each deployment path, not a guessed order, Spring outbox polling: cap work per tick and measure backlog age.

spring
configuration
testing
Storage details