类似错误有:
-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>
- 解决办法二
pom.xml
<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>