Environment: Environment variable Java_home configuration jdk1.8
The idea configuration supports lambda:
File, Project Structure, Modules, Language level, select: 8-lambdas, type annotations etc.
Project language level, Project Structure, File, Project, select: 8-lambdas, type annotations etc.
The configuration of the compiler in the Pom file:
<build>
<finalName>spark.hadoop.study</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
Finally: The core is to specify a source of 1.8, otherwise the compilation will report the following error:
Fatal Error Compiling: Invalid target release
Using Java8 new feature lambda expression in IntelliJ idea