Last active
August 29, 2015 14:00
-
-
Save up1/e2dd6fec192ae33cd31b to your computer and use it in GitHub Desktop.
Demo-Dropwizrd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server: | |
applicationConnectors: | |
- type: http | |
port: 8080 | |
adminConnectors: | |
- type: http | |
port: 8081 | |
# Logging settings. | |
logging: | |
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. | |
level: INFO | |
# Logger-specific levels. | |
loggers: | |
# Sets the level for 'com.example.app' to DEBUG. | |
up1.demo: DEBUG | |
appenders: | |
- type: console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package up1.demo; | |
import health.TemplateHealthCheck; | |
import io.dropwizard.Application; | |
import io.dropwizard.setup.Bootstrap; | |
import io.dropwizard.setup.Environment; | |
import resource.DemoResource; | |
public class DemoApplication extends Application<DemoConfiguration> { | |
public static void main(String[] args) throws Exception { | |
new DemoApplication().run(args); | |
} | |
@Override | |
public String getName() { | |
return "Demo"; | |
} | |
@Override | |
public void initialize(Bootstrap<DemoConfiguration> arg0) { | |
} | |
@Override | |
public void run(DemoConfiguration configuration, Environment environment) throws Exception { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void run(DemoConfiguration configuration, Environment environment) throws Exception { | |
DemoResource demoResource = new DemoResource(); | |
environment.jersey().register(demoResource); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package up1.demo; | |
import io.dropwizard.Configuration; | |
public class DemoConfiguration extends Configuration { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package resource; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.QueryParam; | |
import javax.ws.rs.core.MediaType; | |
import up1.demo.value.Message; | |
@Path("/demo") | |
@Produces(MediaType.APPLICATION_JSON) | |
public class DemoResource { | |
@GET | |
public Message sendMessage(@QueryParam("name") String name) { | |
return new Message( "Hello " + name ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package up1.demo.value; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
public class Message { | |
private long id; | |
private String message; | |
public Message() { | |
} | |
public Message(String message) { | |
this.message = message; | |
} | |
@JsonProperty | |
public long getId() { | |
return this.id; | |
} | |
@JsonProperty | |
public String getMessage() { | |
return this.message; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>demo_dropwizard</groupId> | |
<artifactId>demo_dropwizard</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<name>demo_dropwizard</name> | |
<properties> | |
<dropwizard.version>0.7.0</dropwizard.version> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>io.dropwizard</groupId> | |
<artifactId>dropwizard-core</artifactId> | |
<version>${dropwizard.version}</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-enforcer-plugin</artifactId> | |
<version>1.3.1</version> | |
<executions> | |
<execution> | |
<id>enforce</id> | |
<configuration> | |
<rules> | |
<DependencyConvergence /> | |
</rules> | |
</configuration> | |
<goals> | |
<goal>enforce</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<configuration> | |
<source>1.7</source> | |
<target>1.7</target> | |
<encoding>UTF-8</encoding> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-source-plugin</artifactId> | |
<version>2.2.1</version> | |
<executions> | |
<execution> | |
<id>attach-sources</id> | |
<goals> | |
<goal>jar</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>2.4</version> | |
<configuration> | |
<archive> | |
<manifest> | |
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> | |
</manifest> | |
</archive> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>2.2</version> | |
<configuration> | |
<createDependencyReducedPom>true</createDependencyReducedPom> | |
<filters> | |
<filter> | |
<artifact>*:*</artifact> | |
<excludes> | |
<exclude>META-INF/*.SF</exclude> | |
<exclude>META-INF/*.DSA</exclude> | |
<exclude>META-INF/*.RSA</exclude> | |
</excludes> | |
</filter> | |
</filters> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
<configuration> | |
<transformers> | |
<transformer | |
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> | |
<transformer | |
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | |
<mainClass>up1.demo.DemoApplication</mainClass> | |
</transformer> | |
</transformers> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-deploy-plugin</artifactId> | |
<version>2.7</version> | |
<configuration> | |
<skip>true</skip> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-site-plugin</artifactId> | |
<version>3.3</version> | |
<configuration> | |
<skip>true</skip> | |
<skipDeploy>true</skipDeploy> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment