Getting error: Route() in Route cannot be applied to String

apache-spark, java, mongodb

Solution

This should probably be posted on the MongoDB class forum, but I ran into a similar issue. Looks like the get method changed from when the course material was produced. The get now requires a path and a Route

get(path, Route)

import spark.Request;
import spark.Response;
import spark.Route;
import spark.Spark;

public class HelloWorldSparkStyle {
    public static void main(String[] args){

        Spark.get("/", new Route() {
                public Object handle(final Request request, final Response response){
                return "Hello World from Spark";
            }
        });
    }
}

Problem

I'm designing a Java based MongoDB app and I've ran into a snag when working with Spark. ``` package com.tengen; import spark.Request; import spark.Response; import spark.Route; import spark.Spark; public class HelloWorldSparkStyle { public static void main(String[] args) { Spark.get(new Route("/") { @Override public Object handle(Request request, Response response) { return "Hello World From Spark"; } }); } } ``` On new `Route("/")` I get the error `Route() in route cannot be applied to java.lang.string`. I'm confused as to why this doesn't work as I've followed their code exactly.

Original source