把 IntelliJ 从 Java 12 换到 Java 16 后编译我的 Java 16 项目遇到提示说:
By default, the Java language level is set to 5 which is not supported by the current Java version.
直接点击升级,结果说我已经升级了:
最后的解决方案是在 pom.xml 里增加下面的内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>