Sivasankar Sivasankar - 3 months ago 15x
Java Question

SparkJava Web get(string, Route) in the type spark is not applicable

I am building a simple REST API with Spark Java framework. I encountered this issue and not sure why this is happening. If it worked for

get("/".(req,res) -> "Hello World"

But did not work when I use

(request, response) -> {}

Am I missing any libraries?

My dependency looks like this:


import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/",(request, response) -> {
post("/transaction/add", (request, response) -> {

Error message for the method:

enter image description here


It's Route source.

public interface Route {
    Object handle(Request arg0, Response arg1) throws Exception;

You have to return Object in lambda expression!