gpt4 book ai didi

java - -source 1.7 不支持 lambda 表达式

转载 作者:行者123 更新时间:2023-12-04 16:24:09 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





maven. lambda expressions are not supported in -source 1.5

(3 个回答)


4年前关闭。




我在 Eclipse 中打开了 Maven 项目。但是当我清理并安装时,出现上述错误。

我将构建路径更改为使用 SE 1.8,并且我的编译器也配置为使用 1.8。您可以在以下屏幕截图中看到这一点。

enter image description here

enter image description here

我也在项目浏览器中看到了小红叉。你可以在下图中看到。

enter image description here

当我在 Eclipse 中将其配置为使用 1.8 时,我不确定为什么 maven 使用 SE 1.7。

最佳答案

编译时需要配置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>

关于java - -source 1.7 不支持 lambda 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41823398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com