首页 > 其他 > 详细

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

时间:2017-07-29 22:05:37      阅读:452      评论:0      收藏:0      [点我收藏+]

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>

 

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

原文:http://www.cnblogs.com/tongxuping/p/7257623.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!