Spark Java – Expose your endpoints with minimal efforts

I tried spring boot, dropwizard, vertx, play, spring MVC. Then thought why don’t play with SparkJava.

Spark Java – A tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effort. This is what their official website tell about them.

Open your favorite editor. Paste this code. By the do include your dependency.

import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -> "Hello World");
    }
}

And then hit Run, 
View it on : http://localhost:4567/hello

Working example can be found here.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s