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

Spring Boot extensionless config file: give the loader a properties hint

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

An extensionless imported file needs an extension hint so Spring Boot can parse its contents as properties.

Download Spring source kit

Name the format in the import

The test creates a file named relay-values with no suffix. It contains relay.batch-size=47 and relay.timeout=2s. application.properties imports that file URI with [.properties] appended. The child reports batch 47 and timeout 2000 milliseconds. This verifies parsing of one actual extensionless local file rather than a hand-built property map.

Some mounted files lack conventional extensions. An extension hint selects a loader without renaming the file supplied by the platform. The file remains a fixed URI; a relative import follows a different path rule.

Do not overstate the mount evidence

The file is written by the test in a temporary directory. No platform injects it and no secret value is present. The case does not check YAML, alternate encodings, permission errors or rotation. A configtree is another option when each file represents one key.

A successful parse is only the first step. Keep typed validation for ranges, endpoint shape and cross-setting constraints.

Checked source

properties
spring.config.import=file:/absolute/path/relay-values[.properties]
# relay-values has no extension and contains relay.batch-size=47

Verification boundary

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

Common Mistakes

  • Do not expect the loader to infer every extensionless file format.
  • Do not confuse a fixed file URI with a relative import.
  • Do not call a temporary-file test a production platform mount test.

Read next

Spring Boot configtree: bind one file per property in a child JVM, Spring Boot nested config imports: each file becomes the next base directory, Spring Boot external config file: bind the value the process actually loads, Spring Boot file-tree tests: prove binding without claiming secret delivery.

spring
configuration
testing
Storage details