环境: 环境变量JAVA_HOME配置jdk1.8

idea配置支持lambda:

    File -> Project Structure -> Modules ->  Language level, 选择: 8-Lambdas, type annotations etc.

    File -> Project Structure -> Project  ->  Project language level, 选择: 8-Lambdas, type annotations etc.

pom文件中对编译器的配置:

IntelliJ Idea中使用Java8新特性lambda表达式

<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>

最后:核心是指定source为1.8, 否则编译会报如下错误:

Fatal error compiling: 无效的目标发行版

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-08-03
  • 2021-06-01
  • 2021-08-19
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2021-08-01
  • 2021-10-05
  • 2021-06-20
  • 2021-06-24
  • 2022-12-23
相关资源
相似解决方案