Dropwizard Example, Step by Step
The dropwizard-example module provides you with a working Dropwizard Example Application.
Preconditions
Make sure you have Maven installed
Make sure
JAVA_HOMEpoints at JDK 17Make sure you have
curl
Preparations to start the Dropwizard Example Application
Open a terminal / cmd
Navigate to the project folder of the Dropwizard Example Application
mvn clean installjava -jar target/dropwizard-example-5.0.0-SNAPSHOT.jar db migrate example.ymlThe statement above ran the liquibase migration in
/src/main/resources/migrations.xml, creating the table schema
Starting the Dropwizard Example Application
You can now start the Dropwizard Example Application by running
java -jar target/dropwizard-example-5.0.0-SNAPSHOT.jar server example.ymlAlternatively, you can run the Dropwizard Example Application in your IDE:
com.example.helloworld.HelloWorldApplication server example.yml
Working with the Dropwizard Example Application
Insert a new person:
curl -H "Content-Type: application/json" -d '{"fullName":"John Doe", "jobTitle" : "Chief Wizard" }' http://localhost:8080/peopleRetrieve that person:
curl http://localhost:8080/people/1View that person in a freemarker template: curl or open in a browser
http://localhost:8080/people/1/view_freemarkerView that person in a mustache template: curl or open in a browser
http://localhost:8080/people/1/view_mustache