類似錯誤有:
-source 1.6 中不支援 diamond 運算符
[ERROR] (請使用 -source 7 或更高版本以啟用 diamond 運算符)
-source 1.6 中不支援方法引用
[ERROR] (請使用 -source 8 或更高版本以啟用方法引用)
-source 1.6 中不支援 lambda 表達式
[ERROR] (請使用 -source 8 或更高版本以啟用 lambda 表達式)
-source 1.6 中不支援轉換中的交叉類型
[ERROR] (請使用 -source 8 或更高版本以啟用預設方法)
-source 1.6 中不支援文字中存在下劃線
[ERROR] (請使用 -source 7 或更高版本以允許文字中存在下劃線)
-source 1.6 中不支援 multi-catch 語句
[ERROR] (請使用 -source 7 或更高版本以啟用 multi-catch 語句)
- 解決辦法一
pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
- 解決辦法二
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>