A required config import inside an imported file is still required when Boot starts a new process.
Spring Boot nested import failure: a missing second hop must stop startup
Reject the incomplete chain
The test creates config/application.properties and config/relay/worker.properties. The worker imports overrides/missing.properties, but that file is absent. The child exits nonzero without printing a bound batch. The failure is observed at startup, before the probe can use RelaySettings. The successful chain supplies the same kind of second hop and reaches a final batch value.
A required import gives a stronger release signal than an optional fallback. A service may otherwise run with the first file’s defaults even though an operator thought a later file was present. The first-hop missing-file test covers a different path.
Keep the failure claim narrow
The assertion checks exit status and absence of the success marker. It avoids coupling to Boot’s outer exception text, which can change between releases. It does not check bad permissions, an empty but existing file, a malformed value, or a file removed after startup. The typed-value case addresses one of those separate failures.
Checked source
// config/relay/worker.properties
spring.config.import=overrides/missing.properties
// No config/relay/overrides/missing.properties exists.Verification boundary
RelaySettingsProcessTest.missingSecondRelativeImportStopsTheChildProcess. The full fixture is in the downloadable source kit.
Common Mistakes
- Do not mark an operator-owned file optional solely to hide a bad path.
- Do not assert one exact wrapper exception across Boot versions.
- Do not confuse a missing file with a file containing an invalid key.
Read next
Spring Boot nested config imports: each file becomes the next base directory, Spring Boot config import: fail startup when a required file is missing, Spring Boot required import: fail when a relative file is missing, Spring Boot required configtree: reject an absent directory.
