IntelliJ 2021.2.2 gives error 'java: error: invalid source release: 18' when compiling program

IntelliJ 2021.2.2 gives error 'java: error: invalid source release: 18' when compiling program

我在这里查看了很多答案,但没有找到任何有用的信息。我正在使用 java 版本 16.0.1 我的程序不使用 maven 或 gradle。该程序运行良好,直到我今天早些时候更新了我的 ij。

完整错误:

    Executing pre-compile tasks...
    Loading Ant configuration...
    Running Ant tasks...
    Running 'before' tasks
    Checking sources
    Parsing java... [Adexo]
    java: error: invalid source release: 18
    Checking dependencies... [Adexo]
    Dependency analysis found 0 affected files
    Errors occurred while compiling module 'Adexo'
    javac 11 was used to compile java sources
    Finished, saving caches...
    Module 'Adexo' was fully rebuilt due to project configuration/dependencies changes
    Compilation failed: errors: 1; warnings: 0
    Executing post-compile tasks...
    Loading Ant configuration...
    Running Ant tasks...
    Synchronizing output directories...

    30.9.2021 22:34 - Build completed with 1 error and 0 warnings in 3 sec, 279 ms

以下是 .idea 和 .iml 文件中的文件:https://1drv.ms/u/s!AoGu278qdPOWgm-D3ns61-gqA4Ts?e=OWg0NB

如果您需要更多信息,请告知 (:

.idea/misc.xml 由于某种原因指定的语言级别不正确 (JDK_X):

<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">

关闭项目,将 languageLevel 更改为 16,看看是否有帮助。

有一个related bug reported,但应该在IntelliJ IDEA 2020.2及以后的版本中修复了。可能是回归。