IntelliJ IDEA 告诉我“错误:java:编译失败:内部 java 编译器错误想法”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42966889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IntelliJ IDEA tells me "Error:java: Compilation failed: internal java compiler error idea"
提问by ieatczp
When I compile a Java project using IntelliJ IDEA, it gives me the following output (and error):
当我使用 IntelliJ IDEA 编译 Java 项目时,它给了我以下输出(和错误):
Information:Eclipse compiler 4.6.2 was used to compile java sources
Information:Module "sinoWeb" was fully rebuilt due to project configuration/dependencies changes
Information:2017/3/23 11:44 - Compilation completed with 1 error and 0 warnings in 5m 32s 949ms
Error:java: Compilation failed: internal java compiler error
I'm quite confused confused by this! Below are my settings:
我对此很困惑!以下是我的设置:
回答by omerhakanbilici
回答by sezerug
回答by Chris K.
Changing the Language Level in the Project Settings (Ctrl + Alt + Shift + S) to Java 8 solved the problem for me
将项目设置中的语言级别(Ctrl + Alt + Shift + S)更改为 Java 8 为我解决了这个问题
回答by Musab Bozkurt
- On Intellij IDEA Ctrl + Alt + Sto open settings.
- Build, Execution, Deployment-> Compiler-> Java Compiler
- choose your java version from Project bytecode version
- Uncheck Use compiler from module target JDK when possible
- click applyand ok.
- 在Intellij IDEA Ctrl + Alt + S上打开设置。
- 构建、执行、部署->编译器-> Java 编译器
- 从项目字节码版本中选择您的 Java版本
- 尽可能取消选中从模块目标 JDK 使用编译器
- 单击应用并确定。
回答by Duc Hiep Hoang
回答by Tony BenBrahim
In my case, using Java 11, I had:
就我而言,使用 Java 11,我有:
public List<String> foo() {
...
return response.readEntity(new GenericType<List<String>>() {});
and Intellij suggested I should use <>
instead of GenericType<List<String>>
, as such:
和 Intellij 建议我应该使用<>
而不是GenericType<List<String>>
,因此:
public List<String> foo() {
...
return response.readEntity(new GenericType<>() {});
I did that in four functions and the project stopped compiling with an internal compiler error, reverted and it compiled again. Looks like a bug with type inference.
我在四个函数中做到了这一点,项目停止编译并出现内部编译器错误,恢复并再次编译。看起来像类型推断的错误。
回答by Filomat
In my case it was because of lombok
library with intellij 2019.2 & java11.
就我而言,这是因为lombok
带有 intellij 2019.2 和 java11的库。
According to this IDEA bugafter workaround idea works again:
根据此 IDEA 错误,解决方法的想法再次起作用:
Disable all building from intelliJ and dedicate the build to Maven.
Disable all building from intelliJ and dedicate the build to Maven.
回答by velocity
回答by dev_in_progress
In my case, it was response type in restTemplate
:
ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
eurl,
HttpMethod.POST,
requestEntity,
new ParameterizedTypeReference<>() { <---- this causes error
}
);
Should be like this:
应该是这样的:
ParameterizedTypeReference<Map<String, Integer>> responseType = new ParameterizedTypeReference<>() {};
ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
url,
HttpMethod.POST,
requestEntity,
responseType
);