启用idea java8 lambda 环境配置

在使用idea下编写lambda表达式的时候,发现IDE报如下错误:lambda expressions are not supported at this language level,经过一番摆弄,终于把环境配置好了,具体解决办法如下:

  • 设置当前模块语言级别:

    1. 操作链路:File -->Project Structure... -->Project ,在打开的对话窗口中:
    2. Project SDK配置项设置为:java8 sdk (根据idea java8 sdk具体名字配置)
    3. Project Language Level配置项设置为:8 - Lamdas, type annotations etc.
  • 配置maven插件编译器级别1.8

      <build>
          <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>3.6.1</version>
                  <configuration>
                      <source>1.8</source>
                      <target>1.8</target>
                  </configuration>
              </plugin>
          </plugins>
      </build>