IDEA编译模块错误errors occurred while compiling module

当运行程序报如下错误时:

Information:java: Errors occurred while compiling module ‘XXXX’
Error:java: Compilation failed: internal java compiler error

这是由编译时,JDK版本号不一致造成的错误,应该配置以下几处的版本号一致:

  1. 修改 “Language level” 和 “Module SDK”
    选择 File --> project Structure --> Modules,选择项目修改 “Sources” 选项卡下的 “Language level” 及 “Dependencies”选项卡下的 “Module SDK” 。
    IDEA编译模块错误errors occurred while compiling module
    IDEA编译模块错误errors occurred while compiling module
  2. 修改Java Compiler
    IntelliJ IDEA --> Preferences --> Build,Execution,Deployment --> Compiler --> java Compiler
    IDEA编译模块错误errors occurred while compiling module