使用MAVEN请注意,MAVEN不支持最新版jdk1.7

最新说明:MAVEN对1.7的支持没问题,但是如果你遇到和jdk有关的莫名其妙的问题,可以尝试换个版本试试。


MAVEN官网最新版本的系统要求


System Requirements

JDKMaven 3.2 requires JDK 1.6 or above, while Maven 3.0/3.1 requires JDK 1.5 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's)
MemoryNo minimum requirement
DiskNo minimum requirement. Approximately 100MB will be used for your local repository, however this will vary depending on usage and can be removed and redownloaded at any time.
Operating SystemNo minimum requirement. On Windows, Windows NT and above or Cygwin is required for the startup scripts. Tested on Windows XP, Fedora Core and Mac OS X.


系统要求jdk1.6或以上,但是我最近电脑重装系统之后,不想安装太多版本jdk,所以就安装了1.7的最新版。

没想到使用MAVEN的时候,总是无法下载插件,无法联网,就算增加源也解决不了问题,很费解。在Google上查询结果后也没有找到解决办法。


MAVEN错误信息如下:

Downloading: http://maven.oschina.net/content/groups/public/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
三月 06, 2014 8:40:45 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: I/O exception (java.net.SocketException) caught when processing request: Connection reset
三月 06, 2014 8:40:45 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: Retrying request
三月 06, 2014 8:41:27 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: I/O exception (java.net.SocketException) caught when processing request: Connection reset
三月 06, 2014 8:41:27 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: Retrying request
三月 06, 2014 8:42:09 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: I/O exception (java.net.SocketException) caught when processing request: Connection reset
三月 06, 2014 8:42:09 下午 org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
信息: Retrying request


[ERROR] Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.ap
ache.maven.plugins:maven-install-plugin:jar:2.4: Could not transfer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.4 from/to nexus-osc (http://maven.oschina.net/content/groups/public/): Connection reset -> [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/PluginResolutionException


从错误信息来看,只能从java.net.SocketException入手,因为我其他电脑上的jdk都是1.6,1.7同时存在,而且JAVA_HOME都配置的1.6,所以觉得可能是这方面的问题。

没有换JDK之前:

D:\Git>mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T01:37:52+08:00)
Maven home: C:\Program Files\apache-maven
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_45\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"


换了JDK之后:

D:\Git>mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T01:37:52+08:00)
Maven home: C:\Program Files\apache-maven
Java version: 1.6.0_43, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_43\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"


再之后,运行MAVEN就没有问题了。


如果有人遇到类似的问题,可以换个低版本的JDK试试。我电脑安装的都是64位版本,32位没有测试是否有问题。


使用IDEA或Eclipse的还需要在IDE中对MAVEN的jdk进行修改。已知IDEA需要修改两处。Eclipse暂时没试,估计不用改。


解决问题的方法确实简单,不过由于过于相信MAVEN官方说明,因而没考虑到JDK版本的问题,实在是浪费时间。

  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

isea533

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值