public class PklResolver implements Resolver {
public Optional<String> resolve(InvocationContext context, String propertyName) {
return getFromPklConfig(propertyName);
}
}
// Register custom resolver when building ExternalizedProperties
ExternalizedProperties externalizedProperties = ExternalizedProperties.builder()
.resolvers(new PklResolver(...))
.build();
AppProperties appProperties = externalizedProperties.initialize(AppProperties.class);
// Resolves config from PklResolver
String myConfig = appProperties.myConfig();
By using ExternalizedProperties instead of direct System.getenv() you get other useful features such as automatic conversions, variable expansion, and processing (e.g. automatic decryption/automatic base64 decode, etc)