This is an example Dropwizard app using Scala.
-
Dropwizard 1.0.4
-
Scala-2.12.0
-
Java 8
-
Maven 3
-
Guice dependency injection
-
JSON and XML serialization using Java and Scala entities
-
Example resource , health check, filter.
mvn clean package java -jar target/dropwizard-scala-example.jar server src/main/resources/config.yml
This assumes you have a working docker environment
mvn clean package docker build -t dropwizard-scala-example . docker run dropwizard-scala-example
docker run -i -t dropwizard-scala-example /bin/bash
Tip
|
make dist image run builds and runs docker image.
|
Example (serialize plain Java/Scala object to JSON)
curl -v http://127.0.0.1:8080/example/scala/json curl -v http://127.0.0.1:8080/example/java/json
Example (serialize Java/Scala entity with JAXB annotation to XML)
curl -v http://127.0.0.1:8080/example/scala/xml curl -v http://127.0.0.1:8080/example/java/xml
Example (serialize Java/Scala entity with JAXB annotation to either JSON or XML)
curl -v -H "Accept:application/json" http://127.0.0.1:8080/example/scala curl -v -H "Accept:application/xml" http://127.0.0.1:8080/example/scala curl -v -H "Accept:application/json" http://127.0.0.1:8080/example/java curl -v -H "Accept:application/xml" http://127.0.0.1:8080/example/java