idea中解决Error:java: Compilation failed: internal java compiler error的问题

项目中,使用gradle做项目构建,当我们想更改JDK的版本时,报以下错误:

Information:Using javac 1.8.0_111 to compile java sources
Information:java: javacTask: 源发行版 1.8 需要目标发行版 1.8
Information:java: Errors occurred while compiling module 'Spring_1_main'
Information:2018/1/4 18:46 - Compilation completed with 1 error and 0 warnings in 3s 768ms
Error:java: Compilation failed: internal java compiler error

其实有几个地方要改:

1. 更改build.gradle文件

    sourceCompatibility = 1.8

2. 更改.idea/compiler.xml文件

<bytecodeTargetLevel>
      <module name="common_main" target="1.8" />
      <module name="common_test" target="1.8" />
      <module name="questionnaire_main" target="1.8" />
      <module name="questionnaire_test" target="1.8" />
</bytecodeTargetLevel>

3. 更改File->Project Structure->Project Settings->Modules->项目名称->右侧的Dependencies->Module SDK

    

4. 在Settings->Buile,Execution,Deployment->Compiler->Java Compiler设置Module的Target bytecode version

posted @ 2018-01-30 17:35  飞鱼君  阅读(39560)  评论(1编辑  收藏  举报