您的位置:首页 > 其它

IntelliJ Idea编译报错:请使用 -source 7 或更高版本以启用 diamond 运算符

2017-02-28 00:00 411 查看
IntelliJ Idea maven项目编译报错:

Information:Using javac 1.7.0_79 to compile java sources
Information:java: javacTask: 源发行版 1.7 需要目标发行版 1.7
Information:java: Errors occurred while compiling module 'wsdlutils'
Information:2016/4/13 16:42 - Compilation completed with 1 error and 0 warnings in 1s 805ms
Error:java: Compilation failed: internal java compiler error


参考文章[http://blog.csdn.net/wave_1102/article/details/47671019]都不能解决问题。

原来在IntelliJ Idea 默认的jdk是1.5。以上的修改都不会起作用的。见【https://maven.apache.org/plugins/maven-compiler-plugin/】

Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target as described in Setting the -source and -target of the Java Compiler.


在项目的pom文件中加以下内容:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>


官网上也有说明[https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html]

<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐