一直在用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