Maven 编译错误:(使用 -source 7 或更高版本来启用菱形运算符) [英] Maven Compilation Error: (use -source 7 or higher to enable diamond operator)
本文介绍了Maven 编译错误:(使用 -source 7 或更高版本来启用菱形运算符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 IntelliJ、JDK1.8、maven 3.2.5 中使用 maven.出现编译错误:使用 -source 7 或更高版本来启用钻石歌剧.详情如下:
I'm using maven in IntelliJ, JDK1.8, maven 3.2.5. Got compilation error: use -source 7 or higher to enable diamond opera. details are as follows:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] TrainingConstructor.java:[31,55] diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
[ERROR] DTM.java:[79,21] try-with-resources is not supported in -source 1.5 (use -source 7 or higher to enable try-with-resources)
[ERROR] ticons.java:[53,44] diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
有什么建议吗?是否还有其他配置可以设置此 -source 级别?似乎它不使用 java 1.8.
Any suggestions? Is there any other configuration to set this -source level? seems it doesn't use java 1.8.
推荐答案
检查你的 maven-compiler-plugin
是如何配置的,它应该使用 java 7 或更高版本:
Check how your maven-compiler-plugin
is configured, it should use java version 7 or higher:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
要获得更完整的答案,请参阅以下内容.
For a more complete answer see the one below.
这篇关于Maven 编译错误:(使用 -source 7 或更高版本来启用菱形运算符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文