Peter
01/24/2022, 10:45 PMPeter
01/24/2022, 10:46 PMredis {
host = ${MY_REDIS_HOST}
port = ${MY_REDIS_PORT}
}
Peter
01/24/2022, 10:46 PMPeter
01/24/2022, 10:46 PMPeter
01/24/2022, 10:47 PMdata class RedisConfig(host: String, port: Int)
i’ll end up with RedisConfig("..", 6379)
Peter
01/24/2022, 10:47 PMRedisConfig("..", 6378)
sam
01/24/2022, 10:47 PMsam
01/24/2022, 10:48 PMsam
01/24/2022, 10:48 PMsam
01/24/2022, 10:48 PMsam
01/24/2022, 10:48 PMsam
01/24/2022, 10:48 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 PMsam
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 PMsam
01/24/2022, 10:52 PMPeter
01/24/2022, 10:52 PMsam
01/24/2022, 10:52 PMsam
01/24/2022, 10:52 PMPeter
01/24/2022, 10:53 PMsam
01/24/2022, 10:53 PMsam
01/24/2022, 10:53 PMEnvironmentVariablesPropertySource
, SystemPropertiesPropertySource
and UserSettingsPropertySource
sources are automatically registered, with precedence in that ordersam
01/24/2022, 10:54 PMEnvironmentVariablesPropertySource
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.sam
01/24/2022, 10:54 PMsam
01/24/2022, 10:55 PMPeter
01/24/2022, 10:55 PMhost = ${MY_REDIS_HOST}
?Peter
01/24/2022, 10:56 PMMY_REDIS_HOST
sam
01/24/2022, 10:56 PMsam
01/24/2022, 10:56 PMsam
01/24/2022, 10:56 PMsam
01/24/2022, 10:56 PMPeter
01/24/2022, 10:56 PMsam
01/24/2022, 10:57 PMredis.port
an envsam
01/24/2022, 10:57 PMsam
01/24/2022, 10:57 PMPeter
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