This website will be used to collect tutorials about Spark. We aim to provide one tutorial every month until summer:
- April 2015: Spark for REST APIs: Using Spark, Lombok and Jackson to reduce Java boilerplate
- May 2015: Spark and data persistence: Integration with sql2o
- June 2015: Spark for websites: Working with Freemarker
- July 2015: Spark in the Cloud: AWS and Docker
Getting started with Spark
Add the maven dependency:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.1</version>
</dependency>
Setup your first route:
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
Run and view:
http://localhost:4567/hello
Easy, right? Now check out some other tutorials and start coding!