Sample Spark application using Jetty server, built with Gradle
- Gradle 1.12
- JDK 1.8
I have used the Unlicense. Ideas aren't property. Use this code however you want. If you think I deserve credit for code here, feel free to acknowledge the provenance of the ideas you use. But you don't have to.
The purpose of this repository is to show you how a Gradle + Spark project should be configured so the application you write will run on a web server or servlet container (like jetty).
Run this at a prompt:
gradle jettyRun
The application server will listen on 0.0.0.0:8080
by default. See Spark docs.
Run in an empty directory
gradle init --type basic
Change the build.gradle
file to look similar to the one here. Create src/main/java
, and fill it with happiness and sunshine. See the Spark docs.
Create src/main/webapp/WEB-INF
. Gradle's Jetty plugin expects the directory to exist, and Java servlet containers need the directory to contain a web.xml
file for some damned reason or another. See the copy in this repo, and read Spark's docs. It's not too complicated.
That's it. Now you have a Spark application that you can flesh out and build with Gradle. See the discussion above about running the sample.