用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
我的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>
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(); } }
找到原因了
以下这样写编译不通过
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>();
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。