Maven编译错误:(使用-source 7或更高版本启用菱形运算符) [英] Maven Compilation Error: (use -source 7 or higher to enable diamond operator)

查看:467
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆