Skip to content

Instantly share code, notes, and snippets.

Last active July 12, 2018 14:20
What would you like to do?
import io.dropwizard.Application;
import io.dropwizard.db.DataSourceFactory;
import io.dropwizard.hibernate.HibernateBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
* Created by harshvardhan on 12/07/18.
public class MyApplication extends Application<MyConfiguration> {
public static void main(String[] args) throws Exception {
new MyApplication().run(args);
public void run(MyConfiguration myConfiguration, Environment environment) throws Exception {
System.out.println("Value from dev.yml is "+myConfiguration.getDataSourceFactory().getUser());
InfoDao infoDao = new InfoDao(hibernate.getSessionFactory());
final MyResource resource = new MyResource(infoDao);
private HibernateBundle<MyConfiguration> hibernate = new HibernateBundle<MyConfiguration>(Info.class) {
public DataSourceFactory getDataSourceFactory(MyConfiguration configuration) {
return configuration.getDataSourceFactory();
public String getName() {
return "dropwizard-hibernate";
public void initialize(Bootstrap<MyConfiguration> bootstrap) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment