Peter
01/24/2022, 10:45 PMredis {
host = ${MY_REDIS_HOST}
port = ${MY_REDIS_PORT}
}
data class RedisConfig(host: String, port: Int)
i’ll end up with RedisConfig("..", 6379)
RedisConfig("..", 6378)
sam
01/24/2022, 10:47 PMPeter
01/24/2022, 10:49 PMredis.port
in the environment is taking precedence over MY_REDIS_PORT
in the environment if i specified MY_REDIS_PORT
in my HOCON config file?sam
01/24/2022, 10:49 PMPeter
01/24/2022, 10:51 PMredis.port
even apply to set the value in HOCON? i know that syntax is supported for reading values from the parsed HOCON configurationsam
01/24/2022, 10:52 PMPeter
01/24/2022, 10:52 PMsam
01/24/2022, 10:52 PMPeter
01/24/2022, 10:53 PMsam
01/24/2022, 10:53 PMEnvironmentVariablesPropertySource
, SystemPropertiesPropertySource
and UserSettingsPropertySource
sources are automatically registered, with precedence in that orderEnvironmentVariablesPropertySource
reads config from environment variables. It does not map cases so HOSTNAME
does not provide a value for a field with the name hostname
.
For nested config, use a period to seperate keys, for example topic.name
would override name
located in a topic
parent. Alternatively, in some environments a .
is not supported in ENV names, so you can also use double underscore __
. Eg topic__name
would override name in a Topic object.
Optionally you can also create a EnvironmentVariablesPropertySource
with allowUppercaseNames
set to true
to allows for uppercase-only names.Peter
01/24/2022, 10:55 PMhost = ${MY_REDIS_HOST}
?MY_REDIS_HOST
sam
01/24/2022, 10:56 PMPeter
01/24/2022, 10:56 PMsam
01/24/2022, 10:57 PMredis.port
an envPeter
01/24/2022, 10:57 PMEnvironmentVariablesPropertySource
vs EnvVarPreprocessor
… i missed the distinction there initially 😅sam
01/24/2022, 10:58 PMPeter
01/24/2022, 10:58 PM