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

前端 未结 5 1013
栀梦
栀梦 2021-01-05 18:48

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;
         


        
5条回答
  •  迷失自我
    2021-01-05 19:26

    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";
                }
            });
        }
    }
    

提交回复
热议问题