Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created November 6, 2015 12:58
Show Gist options
  • Select an option

  • Save javaeeeee/53f0f523647bb539b417 to your computer and use it in GitHub Desktop.

Select an option

Save javaeeeee/53f0f523647bb539b417 to your computer and use it in GitHub Desktop.
Changes to Configuration class to enable database connection in a Dropwizard project
public class DWGettingStartedConfiguration extends Configuration {
...
/**
* A factory used to connect to a relational database management system.
* Factories are used by Dropwizard to group together related configuration
* parameters such as database connection driver, URI, password etc.
*/
@NotNull
@Valid
private DataSourceFactory dataSourceFactory
= new DataSourceFactory();
...
/**
* A getter for the database factory.
*
* @return An instance of database factory deserialized from the
* configuration file passed as a command-line argument to the application.
*/
@JsonProperty("database")
public DataSourceFactory getDataSourceFactory() {
return dataSourceFactory;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment