PNS*_*PNS 142 java compilation intellij-idea
尽管在所有项目设置(包括in File -> Project Structure -> Project :: Project SDK)中都指定了JDK 1.7 ,但IntelliJ 13在尝试编译一些使用菱形运算符的简单Java 7代码时会产生以下错误:
java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
Run Code Online (Sandbox Code Playgroud)
配置中是否还有其他位置-source 7应启用预期选项?
Pet*_*mov 152
请检查项目/模块语言级别(项目结构|项目;项目结构|模块|模块名称|来源).您可能还想查看"设置"| 编译器| Java编译器| 每模块字节码版本.
也设置这个:
文件 - >项目结构 - >模块::源(在路径和依赖项旁边),并且具有"语言级别"选项,也需要正确设置.
Djo*_*vic 111
如果没有任何帮助(我的情况),你可以在你的pom.xml中设置它,如下所示:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)
正如这里提到的这个很酷的家伙:https: //stackoverflow.com/a/25888116/1643465
Bir*_*abs 50
[适用于IntelliJ IDEA 2016.2]
我想用最新的截图扩展Peter Gromov答案的一部分.特别是这个特殊部分:
您可能还想查看"设置"| 编译器| Java编译器| 每模块字节码版本.
我相信(至少在2016.2):检查不同的提交将git这些重置为1.5.
Olg*_*zek 18
或者,您可以将maven-compiler-plugin与适当的java版本一起应用到pom.xml中:
<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)
Ana*_*ika 14
我尝试对Intellij IDEA进行如下更改:
1.
File >> Settings >> Build, Execution, Deployment >> Compiler >> Java Compiler >> project bytecode version: 1.8 >> Per-module bytecode version: 1.8
Run Code Online (Sandbox Code Playgroud)
2.
File >> Project Structure >> Project Settings >> Project >> SDK : 1.8, Project Language : 8 - Lambdas
File >> Project Structure >> Project Settings >> Modules >> abc : Language level: 8 - Lambdas
Run Code Online (Sandbox Code Playgroud)
但没有任何效果,只要我保存它就将版本恢复为java 1.5.
但是,将以下行添加到root(项目级别)pom.xml让我解决了上述问题:(这两个选项对我有用)
选项1:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)
选项2:
<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)
| 归档时间: |
|
| 查看次数: |
91352 次 |
| 最近记录: |