A configtree import turns filenames under a directory into Spring Boot property names.
Spring Boot configtree: bind one file per property in a child JVM
Name the files after the properties
The fixture creates a local mounted-values/relay directory with batch-size containing 41 and timeout containing 1500ms. Its application.properties imports the absolute directory using configtree:. A child JVM then reports batch 41 and timeout 1500 milliseconds. Those two values come from real files, not from a manually inserted PropertySource. The environment fixture takes a different input path.
The path passed after configtree: is an absolute directory path ending in a slash. A file: URL after configtree: did not resolve in this pinned fixture, so the checked example uses the directory form directly. Each file contains a value. The file path supplies the key.
Do not expose the payload to prove loading
The two checked values are non-secret settings. A configtree may also carry credentials, but the probe does not read or print one. Diagnose a sensitive import by checking presence, successful binding, and redacted source identity. The boundary page separates these local files from an actual platform secret mount.
A file-tree import is not a live subscription. This test starts once and reads the values at startup; it does not prove that changing a file refreshes an already running bean.
Checked source
spring.config.import=configtree:/absolute/path/mounted-values/
# mounted-values/relay/batch-size contains 41
# mounted-values/relay/timeout contains 1500msVerification boundary
RelaySettingsProcessTest.fileTreeImportBindsValuesWithoutPrintingASecret. The full fixture is in the downloadable source kit.
Common Mistakes
- Do not put a file: URL after configtree: in this checked fixture.
- Do not log a credential to show that a file-tree import worked.
- Do not assume a file change updates a bean without a separate refresh mechanism.
Read next
Spring Boot configtree versus environment: assert the effective value, Spring Boot required configtree: reject an absent directory, Spring Boot configtree validation: reject a present but unsafe value, Spring Boot file-tree tests: prove binding without claiming secret delivery.
