开发者社区> 问答> 正文

用mvn install 编译出错not supported in -sourc?400报错

用mvn install 编译出错not supported in -source 1.5? 400 报错

运行环境

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00)
Maven home: C:\apache-maven-3.2.5-bin\apache-maven-3.2.5
Java version: 1.8.0, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0\jre
Default locale: en_US, platform encoding: GBK
OS name: "windows 8", version: "6.2", arch: "amd64", family: "dos"


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project dddd-web: Compilation failure

[ERROR] /D:/CC/dddd-web/src/main/java/com/xxxx/ddush/controller/PushController.java:[47,54] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


我的pom.xml文件

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>



PushController.java

package com.dddd.ddpush.controller;

import com.dddd.ddpush.core.model.AppPush;
import com.dddd.ddpush.core.service.AppPushService;
import com.skysri.utils.CipherUtil;
import com.skysri.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;

/**
 * Created by giraffe on 15/3/26.
 */
@Controller
@RequestMapping("push")
public class PushController {
    @Autowired
    AppPushService appPushService;

    @RequestMapping("/create")
    @ResponseBody
    public String createPushId(String devId, String appId) {
        String pushId = "";
        String sort = StringUtil.genSalt();
        pushId = CipherUtil.md5(devId + appId + sort); 

        AppPush appPush = new AppPush();
        appPush.setPushId(pushId);
        appPush.setdevId(devId);
        appPush.setAppId(appId);
        appPush.setSort(sort);
        appPush.setCreateTime(new Date());
        appPushService.insert(appPush);
        return pushId;
    }

    @RequestMapping("/get")
    @ResponseBody
    public String getPushId(String devId, String appId) { 
        HashMap<String, Object> params = new HashMap<>();
        params.put("devId", devId);
        params.put("appId", appId);
        AppPush appPush = appPushService.getEntityBy(params);
        return appPush.getPushId();
    }
}



展开
收起
爱吃鱼的程序员 2020-06-04 15:19:52 535 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    找到原因了

    以下这样写编译不通过

    HashMap<String, Object> params = new HashMap<>();

    要改成以下这样才能编译通过

    HashMap<String, Object> params = new HashMap<String, Object>();

    ######请问 new HashMap<>(); 这个是jdk1.7的写法?###### 错误信息中有,让你把maven-compiler插件版本改成3.1
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
             <source>1.6</source>
             <target>1.6</target>
        </configuration>
    </plugin>





    ######

    引用来自“唐小明生”的评论

    找到原因了

    以下这样写编译不通过

    HashMap<String, Object> params = new HashMap<>();

    要改成以下这样才能编译通过

    HashMap<String, Object> params = new HashMap<String, Object>();

    好######1.7
    2020-06-04 16:00:39
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载