使用idea進行maven install老是報-source 1.5 中不支援 lambda 表示式
阿新 • • 發佈:2018-11-24
1、idea的maven設定
2、JDK配置
3、專案模組配置
以上設定均正常,但是在執行maven的install還是報錯:-source 1.5 中不支援 lambda 表示式
另外發現在執行這個步驟,原來的jdk設定會還原成1.5版本
因為程式碼裡面使用了高版本JDK才有的表示式
所以打包肯定是要報錯
所以查詢資料後發現
原來 Maven Compiler 外掛預設會加 -source 1.5 及 -target 1.5 引數來編譯(估計是為了相容一些比較老的 Linux 伺服器作業系統,它們通常只有 JDK 5)(出自: https://www.cnblogs.com/softidea/p/6256543.html)
所以在pom.xml中添加了配置
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>