Use EnvironmentVariablesPropertySource with relaxed binding
masterThe EnvironmentVariablesPropertySource maps environment variables to configuration properties using idiomatic conventions similar to Spring Boot's relaxed binding.
Binding Rules:
- Dots to Underscores:
TOPIC_NAME$\rightarrow$topic.name - Case-Insensitivity:
SPRING_MAIN_LOGSTARTUPINFO$\rightarrow$spring.main.logStartupInfo(matches camelCase fields) - Dashes: Dashes are removed (e.g.,
LOGSTARTUPINFO$\rightarrow$log-startup-infovia@ConfigAlias) - List/Array Indices: Surrounded by underscores (e.g.,
ITEMS_0$\rightarrow$items[0]) - Nested Objects in Lists:
SERVICE_0_OTHER$\rightarrow$service[0].other - Map Keys: The trailing path segment names the key. Note: Unlike Spring, Hoplite preserves the case of the environment variable for map keys (e.g.,
LABELS_ENV=vproduces{"ENV": "v"}).
If an optional prefix is provided to the source, only environment variables starting with that prefix are considered, and the prefix is stripped before processing.