![](/img/trans.png)
[英]IntelliJ IDEA tells me "Error:java: Compilation failed: internal java compiler error idea"
[英]intellij idea internal java compiler error
我正在運行一個與test_harness完全一樣的簡單模式匹配程序
Information:java: Errors occurred while compiling module 'demo_java8'
Information:javac 1.8.0_121 was used to compile java sources
Information:2018-02-06 10:15 - Compilation completed with 1 error and 0 warnings in 376ms
Error:java: Compilation failed: internal java compiler error
但是終端命令javac xxx.java
和java xxx
運行正常。
運行第一個 hello world 程序會出現相同的錯誤。
就我而言,問題是通過將類型參數對象添加到需要它的類實例來解決的。 在以下代碼中,將new ParameterizedTypeReference<>
替換為new ParameterizedTypeReference<Map<String, Object>>
return getRestTemplate().exchange(uri,
HttpMethod.POST,
new HttpEntity<>(headers),
new ParameterizedTypeReference<Map<String, Object>>() {
});
原來,“奇怪”的錯誤描述是因為缺少 maven 插件。 它的默認值為 1.5,而Console
類僅從 1.6 開始可用。 而jar or class cannot be found
,它給出了internal java compiler error
的模糊描述。 Information:javac 1.8.0_121 was used to compile java sources
提示javac版本和sdk版本不匹配。 此外,我很驚訝intellij idea run 函數使用maven build
(我認為它只是為了cli)。
如果我不得不猜測,您的 IntelliJ 使用的是與 IntelliJ 一起打包的 JDK,請嘗試為您的項目設置 JDK,在項目結構中確保 JDK 與您的 Java 環境相匹配。 JDK選擇
如果您使用 Maven 項目,例如,您使用 Java 版本為 1.8,請使用此插件,您可以在其中指定您使用的版本。 工作示例:
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.