Hob*_*ist 826 java intellij-idea java-8
使用IntelliJ IDE无法编译任何项目.以下设置的屏幕截图:
使用JDK:
项目SDK和语言级别:
语言水平:
有人有什么想法吗?
Wes*_*lor 1770
如果你使用Maven
将编译器插件添加到pom.xml
顶级project
节点下:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
(从评论中提到.)
注意:如果您不介意重新导入项目,那么您真正需要做的就是更改pom并重新导入项目,然后IntelliJ将选择正确的设置,您不必手动更改它们.
Ste*_*ner 113
这看起来就像Maven在没有正确配置编译器插件时生成的错误.这是Java 8编译器配置的示例.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ... -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- ... -->
</project>
Run Code Online (Sandbox Code Playgroud)
sno*_*lli 79
java compiler
在设置窗口中,将目标字节码设置为1.8
(或java9的9)
Mar*_*ter 14
关于Maven的许多答案都是正确的,但您不必直接配置插件.
就像在Apache Maven编译器插件的wiki页面上描述的那样,您可以设置插件使用的2个属性.
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
Run Code Online (Sandbox Code Playgroud)
就我而言,我通过打开项目的.iml 文件(它位于项目根文件夹中,名称与项目名称相同)并将行更改<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
为<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
我在此处的其他答案中配置了所有内容,但由于某种原因,Idea 错误地更新了 .iml 文件。
归档时间: |
|
查看次数: |
379271 次 |
最近记录: |