Skip to content

The dropwizard-example project, but set up to build using Gradle instead of Maven

Notifications You must be signed in to change notification settings

ireardon/dropwizard-example-gradle

Repository files navigation

Introduction

This is a port of the dropwizard-example project from Maven to Gradle. You can find the original example project here.

Overview

Included with this application is an example of the optional DB API module. The examples provided illustrate a few of the features available in Hibernate, along with demonstrating how these are used from within Dropwizard.

This database example is comprised of the following classes:

  • The PersonDAO illustrates using the Data Access Object pattern with assisting of Hibernate.

  • The Person illustrates mapping of Java classes to database tables with assisting of JPA annotations.

  • All the JPQL statements for use in the PersonDAO are located in the Person class.

  • migrations.xml illustrates the usage of dropwizard-migrations which can create your database prior to running your application for the first time.

  • The PersonResource and PeopleResource are the REST resource which use the PersonDAO to retrieve data from the database, note the injection of the PersonDAO in their constructors.

As with all the modules the db example is wired up in the initialize function of the HelloWorldApplication.

Running The Application

To test the example application run the following commands.

  • To package the example run the following from the root dropwizard directory.

      ./gradlew clean build
    
  • To setup the h2 database run.

      java -jar target/dropwizard-example-1.2.0-SNAPSHOT.jar db migrate example.yml
    
  • To run the server run.

      java -jar target/dropwizard-example-1.2.0-SNAPSHOT.jar server example.yml
    
  • To hit the Hello World example (hit refresh a few times).

    http://localhost:8080/hello-world

  • To post data into the application.

    curl -H "Content-Type: application/json" -X POST -d '{"fullName":"Other Person","jobTitle":"Other Title"}' http://localhost:8080/people

    open http://localhost:8080/people

About

The dropwizard-example project, but set up to build using Gradle instead of Maven

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published