myeclipse启动maven报错
Maven的安装,Maven安装
我对maven的了解,仅仅局限在百度百科。
由于近期公司需求,我找到了个maven教程:http://wentao365.iteye.com/blog/903396
安装maven其实很简单,就是在Apache官网下载需要的maven包,然后配置环境变量就能跑。(现在的这些工具真方便啊。都不用安装的,什么注册表之类的傻傻分不清。)
配置完,兴奋的打开命令行:“mvn -version”报错了!
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/ma ven/cli/MavenCli : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 1) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl assRealm.java:401) at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass( SelfFirstStrategy.java:42) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl ass(ClassRealm.java:271) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm .java:254) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm .java:239) at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launch er.java:144) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun cher.java:266) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav a:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La uncher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java: 356)
究其原因呢,就是我的java版本太低了,maven版本太高导致的。高版本的Java编译的maven,运行在了低版本的Java上就会出现这样的问题。
知道问题所在就好对症下药了,我有两种方案:一种是升级java版本,一种就是重新下载低版本的maven了。
我由maven3.3.3换成了maven3.0.5,后命令成功执行。
C:\Users\Administrator>mvn -version Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51: 28+0800) Maven home: D:\apache-maven-3.0.5\bin\.. Java version: 1.6.0_43, vendor: Sun Microsystems Inc. Java home: D:\Program Files (x86)\Java\jdk1.6.0_43\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"