IDEA -source 1.5 中不支持 lambda 表達(dá)式解決方法

一直在用scala編寫Spark或者Flink代碼,對(duì)于Java的lambda表達(dá)式一直認(rèn)為沒有前者一直點(diǎn)(".")下去方便,偶然用后者寫代碼中間出現(xiàn)一些小的設(shè)置問題,記錄一下:

示例代碼

final LocalEnvironment env = ExecutionEnvironment.createLocalEnvironment();
final DataSource<Integer> source = env.fromElements(1, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5);
source
    .map(i->i*i)
    .print();

Error:(18, 15) java: -source 1.5 中不支持 lambda 表達(dá)式

Information:java: Errors occurred while compiling module 'flink-suit'
Information:javac 1.8.0_181 was used to compile java sources
Information:Module "flink-suit" was fully rebuilt due to project configuration/dependencies changes
Information:2018/10/1 下午7:17 - Compilation completed with 1 error and 4 warnings in 4s 948ms
Warning:scalac: there was one deprecation warning; re-run with -deprecation for details
Warning:java: 源值1.5已過時(shí), 將在未來所有發(fā)行版中刪除
Warning:java: 目標(biāo)值1.5已過時(shí), 將在未來所有發(fā)行版中刪除
Warning:java: 要隱藏有關(guān)已過時(shí)選項(xiàng)的警告, 請(qǐng)使用 -Xlint:-options。
/Users/neters/computing/flink-suit/src/main/java/com/yidian/data/api/LambdaAPI.java
Error:(18, 15) java: -source 1.5 中不支持 lambda 表達(dá)式
  (請(qǐng)使用 -source 8 或更高版本以啟用 lambda 表達(dá)式)

解決方法:

右鍵點(diǎn)擊工程名->"Open Module Setting"


image.png

Error:java: Compilation failed: internal java compiler error

Information:java: Errors occurred while compiling module 'flink-suit'
Information:javac 1.8.0_181 was used to compile java sources
Information:2018/10/1 下午7:17 - Compilation completed with 1 error and 1 warning in 2s 899ms
Error:java: Compilation failed: internal java compiler error
Warning:scalac: there was one deprecation warning; re-run with -deprecation for details

解決方法:


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容