diamond运算符,指的是JDK1.7的一个新特性。Maven默认用的是JDK1.6去编译。所以需要配置成更高的版本,有以下几种解决办法:

1.在项目pom.xml中加入下面的配置即可

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

2.直接在pom.xml中配置Maven的编译插件

<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>

3.在配置的maven安装包的setting.xml中的profiles标签中加入以下标签

<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>

解决:Java source1.6不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符的更多相关文章

  1. Intellij IDEA新导入项目运行出现Error:(60, 47) java: -source 1.5 中不支持 diamond 运算符 (请使用 -source 7 或更高版本以启用 diamond 运算符)

    后台窗口报错如下: 问题原因 项目jdk版本配置不正确. 解决方案 ①File ->Project Structure ② ③之后还要检查一下这里 Settings-->Build,Exe ...

  2. [bug] maven“1.5不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符”

    原因 maven打包默认采用jdk 1.5,无法识别<> 解决 在pom.xml中加入: <properties> <maven.compiler.source>1 ...

  3. Error:(18, 51) java: -source 1.5 中不支持 diamond 运算符 (请使用 -source 7 或更高版本以启用 diamond 运算符)

    问题:主要是因为jdk版本不一样 解决: 方法一:List<String> list=new ArrayList<Stirng>(); 方法二:重新安装jdk8的版本(安装和配 ...

  4. Error:(18, 51) java: -source 1.5 中不支持 diamond 运算符 (请使用 -source 7 或更高版本以启用 diamond 运算符)

    问题:主要是因为jdk版本不一样 解决: 方法一:List<String> list=new ArrayList<Stirng>(); 方法二:重新安装jdk8的版本(安装和配 ...

  5. 错误:在maven install是抛出 “1.5不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符”

    Maven默认用的是JDK1.5去编译 diamond运算符,有的书翻译为菱形,有的书写的是钻石语法,指的是JDK1.7的一个新特性 List<String> list = new Arr ...

  6. springboot 使用maven 打包 报 (请使用 -source 7 或更高版本以启用 diamond 运算符) 错误解决办法

    在使用springboot maven 打包时 报如下错误 (请使用 -source 7 或更高版本以启用 diamond 运算符) pom.xml编译插件 配置如下: <plugin> ...

  7. 转发:maven打包时始终出现以下提示:-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)

    maven打包时始终出现以下提示: 1.-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)List<User> userList= new Array ...

  8. 运行开源项目,报错Error:(48, 37) 错误: -source 1.6 中不支持 diamond 运算符,请使用-source 7或者更高版本已启用diamond运算符

    错误定位 当时并没有弄明白为什么会出错,一脸懵逼相 解决办法: 将source compatibility和target compatibility都改为1.7,重新build就ok了. 错误原因: ...

  9. Error:(4, 13) java: -source 1.5 中不支持默认方法 (请使用 -source 8 或更高版本以启用默认方法)

随机推荐

  1. 【微信小程序】抽象组件使用示例

        1.配置页面路径 ./app.json { "pages":[ "pages/index/index", "pages/logs/logs&q ...

  2. 被严重误会?APS系统没有想象的那么复杂

    APS的出现要从90年代了,但到现在,很多行业内的顾问或用户提到APS都马上想到的是“要求很精确”“难度很大”“脱离实际”“太理想化”“工作量太大”等等,然后把它束之高阁不睬. 在这里,给大家分析一下 ...

  3. C++ OpenSSL 之四:CER转换为PEM

    1.等同于使用: openssl  x509 -in "cer_path" -inform DER -out "save_path" -outform PEM ...

  4. php策略模式(strategy pattern)

    ... <?php /* The strategy pattern defines a family of algorithms, each of which is encapsulated a ...

  5. rhel6安装rabbitmq-sever

    1.下载rabbitmq-sever3.7.7,我下的是RHEL/CentOS 6.x, 你的系统是哪个版本就下哪个https://github.com/rabbitmq/ Downloadson G ...

  6. 15-cmake语法-math

    math 数学表达式 math(EXPR <output variable> <math expression>) 例子: math(EXPR VAR "${VAR} ...

  7. 生成随机文件名JS

    export default function (length) { const data = ["0", "1", "2", " ...

  8. opencv4.0.0+cmake编译(含contrib)

    https://blog.csdn.net/bobo184/article/details/88749651 前言笔者环境:win10+vs2015+cmake3.8.2 介绍下4.0.0的新特性,沿 ...

  9. Debian 安装 yum

    sudo apt-get updatesudo apt-get install build-essentialsudo apt-get install yum

  10. Pandas | 04 Panel 面板

    面板(Panel)是3D容器的数据.面板数据一词来源于计量经济学,部分源于名称:Pandas - pan(el)-da(ta)-s. 3轴(axis)这个名称旨在给出描述涉及面板数据的操作的一些语义. ...