A relative Spring Boot config import can be verified while the process starts outside the configuration directory.
Spring Boot relative config import: change the working directory and inspect the value
Separate file location from launch location
The test writes config/application.properties with relay.batch-size=17, relay.timeout=750ms and spring.config.import=relay/worker.properties. The imported config/relay/worker.properties contains relay.batch-size=29. The child starts in a different launch directory and receives --spring.config.additional-location pointing at config. It reports batch 29 and timeout 750. The path rule is observable in the bound bean rather than assumed from a string.
The imported file wins for its batch key while the declaring file still supplies timeout. Check both values; checking only that startup succeeded could miss a fallback or an unintended source. The source matrix should name this as a distinct row.
Do not turn this into a mount claim
The two directories are temporary directories on one local machine. The test does not mount a container volume, change file permissions or read a secret store. A release test must start the packaged artifact with its actual mount and working directory. The remaining test boundary lists the gaps.
Checked source
relay.batch-size=17
relay.timeout=750ms
spring.config.import=relay/worker.properties
# config/relay/worker.properties: relay.batch-size=29Verification boundary
RelaySettingsProcessTest.relativeImportUsesItsDeclaringFileOutsideTheWorkingDirectory. The source kit contains the full test and entry point.
Common Mistakes
- Do not resolve relay/worker.properties relative to the launch directory.
- Do not assert only that the child started; inspect the effective bean values.
- Do not call temporary directories a production volume mount.
Read next
Spring Boot relative config imports: resolve from the declaring file, Spring Boot required import: fail when a relative file is missing, Spring Boot configuration sources: test each deployment path, not a guessed order, Spring Boot config tests: what a child JVM proves and what deployment still owes.
Checked config-data continuation
Continue with Spring Boot nested config imports: each file becomes the next base directory.
