zoukankan      html  css  js  c++  java
  • 错误:在maven install是抛出 “1.5不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符”

    Maven默认用的是JDK1.5去编译

    diamond运算符,有的书翻译为菱形,有的书写的是钻石语法,指的是JDK1.7的一个新特性

    List<String> list = new ArrayList<String>(); // 老版本写法
    List<String> list = new ArrayList<>(); // JDK1.7写法

    所以Maven默认使用JDK1.5去编译肯定是不认识这个东西的

    你可以在pom.xml中加入下面的东西即可

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

    或者你直接在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>
  • 相关阅读:
    正则表达式
    内涵函数二
    内置函数
    生成器的推导式 表达式
    函数的闭包 迭代器的使用
    函数的动态参数,命名空间
    函数
    文件的操作
    set 集合 拷贝的操作
    u-boot简介
  • 原文地址:https://www.cnblogs.com/tongxuping/p/7257623.html
Copyright © 2011-2022 走看看