I wanted to see how hard it would be to get Dropwizard config from Consul’s key value store. Turns out it is very easy to do!
Make sure you’re using Dropwizard >= 0.8.0, this has the SubstitutingSourceProvider that we’re going to use.
Create a default Dropwizard project with the following configuration line in its config.yml:
Don’t forget to add it to the xxxConfiguration:
@JsonProperty @NotEmpty private String someSetting; Now in the xxxApplication class, register a new ConsulKVSubstitutor in the initialize method: