I want to load a list of structured objects from configuration using Hoplite.
propertyName: <complex object 1>, <complex object 2>, ...
What is the correct syntax for a list of structured objects in the Java properties file?
I tried variations of the following with no success:
application.properties:
lookupValues={key: a, value: 1}, {key: b, value: 2}
AppConfig.kt:
data class ApplicationConfig(
val lookupValues: List<LookupPair>
)
data class LookupPair(val key: String, val value: String)
...
val configLoader = ConfigLoaderBuilder.default()
.addResourceSource("/application.properties")
val config = configLoader.build().loadConfigOrThrow<ApplicationConfig>()
...
It does appear to attempt to parse lookupValues as a list, but then it doesn't successfully parse each element of the list as an instance of LookupPair:
- Could not instantiate 'ApplicationConfig' because:
- 'lookupValues': Collection element decode failure (classpath:/application.properties):
- Could not instantiate 'LookupPair' because:
- 'key': Missing from config
- 'value': Missing from config