- Java: Basic Dropwizard Project
- Dropwizard: Guice Bundle
- Dropwizard: Command
- Dropwizard: Resource
- Dropwizard: Swagger Integration
This tutorial will guide you through how to create a bare bones Dropwizard app. Ensure you have Eclipse installed or whatever IDE you are deciding to use. You can use their documentation as a guide. This is the first tutorial in the dropwizard series.
Setup Eclipse Archetype:
Select new Maven Project then in the select Archetype if dropwizard isn’t there you can add it by using the below settings.
Filter for Dropwizard Archetype:
Set Project Settings:
POM:
Ensure the pom has the correct “dropwizard.version” and that the dependency “dropwizard-core” is there.
Our Configuration:
Now that the project is created let’s have a look at what our configuration looks like. Pretty basic but that’s all we need right now.
- package ca.gaudreault.mydropwizardapp;
- import io.dropwizard.Configuration;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import org.hibernate.validator.constraints.*;
- import javax.validation.constraints.*;
- public class MyDropwizardAppConfiguration extends Configuration {
- }
Our Application:
This is what our application class looks like. It’s empty nothing yet.
- package ca.gaudreault.mydropwizardapp;
- import io.dropwizard.Application;
- import io.dropwizard.setup.Bootstrap;
- import io.dropwizard.setup.Environment;
- public class MyDropwizardAppApplication extends Application {
- public static void main(final String[] args) throws Exception {
- new MyDropwizardAppApplication().run(args);
- }
- @Override
- public String getName() {
- return "MyDropwizardApp";
- }
- @Override
- public void initialize(final Bootstrap bootstrap) {
- }
- @Override
- public void run(final MyDropwizardAppConfiguration configuration,
- final Environment environment) {
- }
- }
Config.yml:
This is what our config.yml file looks like at the start.
- logging:
- level: INFO
- loggers:
- ca.gaudreault: DEBUG
Setup Debug Configuration:
Setup your debug configuration like the below setup.
Running:
Once you run it you will be running two sites.
- http://localhost:8080
- Your main site
- http://localhost:8081
- Your operational site (health, etc)
2 thoughts on “Java: Basic Dropwizard Project”
Comments are closed.