Use configuration imports in Dropwizard instead of copy-pasting files for each environment.
In foodpanda, we've been missing a popular Symfony2 feature which allows to import another file directly from your configuration file.
This can be used to:
- split a large configuration file into multiple smaller snippets
- override environment-dependent values
<dependencies>
<dependency>
<groupId>com.foodpanda</groupId>
<artifactId>dropwizard-config-importable</artifactId>
<version>${current.version}</version>
</dependency>
</dependencies>
compile 'com.foodpanda:dropwizard-config-importable:1.0.1'
Find your HelloApplication.java
class and in the initialize
method add this line:
bootstrap.setConfigurationFactoryFactory(new ImportableConfigurationFactoryFactory<>());
base.yml
:
database:
driverClass: org.postgresql.Driver
logValidationErrors: true
dev.yml
:
imports:
- base.yml
database:
user: postgres
prod.yml
:
imports:
- base.yml
database:
user: ${PROD_DB_USER}
logValidationErrors: false
- Circular reference detection
- Support for other than local file resource types