eclipse -source 1.7 不支持 lambda 表达式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41823398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
lambda expressions are not supported in -source 1.7
提问by Darshan Puranik
I have maven project opened in Eclipse. But when I do clean and install, I get above error.
我在 Eclipse 中打开了 Maven 项目。但是当我进行清理和安装时,出现上述错误。
I changed my build path to use SE 1.8 and my compiler is also configured to use 1.8. You can see that in following screen shots.
我将构建路径更改为使用 SE 1.8,并且我的编译器也配置为使用 1.8。您可以在以下屏幕截图中看到这一点。
I am seeing little red crosses in project explorer too. You can see that in following picture.
我也在项目资源管理器中看到了小红叉。您可以在下图中看到。
I am not sure why maven is using SE 1.7 when I have configured it to use 1.8 in Eclipse.
当我在 Eclipse 中将其配置为使用 1.8 时,我不确定为什么 maven 使用 SE 1.7。
回答by marthursson
You need to configure maven to use 1.8 compatibility when compiling:
编译时需要配置maven使用1.8兼容性:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>utf8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>