我在这里遵循了 tut http://sparkjava.com/documentation.html#getting-started
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>spark</groupId>
<artifactId>Spark</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spark</name>
<description>spark</description>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>
你好.java
import static spark.Spark.*;
public class Hello {
public static void main(String[] args) {
get("/hello", (req, res)-> "Hello World");//eclipse error this line
}
}
eclipse出错了
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
req cannot be resolved to a variable
Syntax error on token ",", . expected
Syntax error on token "-", -- expected
at Hello.main(Hello.java:5)