java - sparkjava and eclipse unresolved compilation problems: -
i have followed tut here 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>
hello.java
import static spark.spark.*; public class hello { public static void main(string[] args) { get("/hello", (req, res)-> "hello world");//eclipse error line } }
i got error eclipse
exception in thread "main" java.lang.error: unresolved compilation problems: req cannot resolved variable syntax error on token ",", . expected syntax error on token "-", -- expected @ hello.main(hello.java:5)
java's lambda expressions feature in java 8: oracle link. you'll need change compliance level (and java version, , pom) java 8 make example compile.
Comments
Post a Comment