`

在Mac平台安裝Maven3

 
阅读更多

在Mac平台安裝Maven


如果有安裝XCode, XCode会自动帮你安裝Maven, 安裝在/usr/share/java/


安裝3.0.3

到http://maven.apache.org/download.html下載maven 3.0.3

将apache-maven-3.0.3-bin.tar.gz解压缩到/usr/share/java

移除/usr/share下的softlink maven

ln -s /usr/share/java/apache-maven-3.0.3 /usr/share/maven

修改~/.profile 设定M3_HOME=/usr/share/java/apache-maven-3.0.3

注意事项


不能同时设M2_HOME与M3_HOME两个环境变量, 不然执行maven会出现以下的exception

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/codehaus/plexus/classworlds/launcher/Launcher  Caused by: 
java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher   at 
java.net.URLClassLoader$1.run(URLClassLoader.java:202)   at 
java.security.AccessController.doPrivileged(Native Method)   at 
java.net.URLClassLoader.findClass(URLClassLoader.java:190)   at 
java.lang.ClassLoader.loadClass(ClassLoader.java:307)   at 
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)   at 
java.lang.ClassLoader.loadClass(ClassLoader.java:248)

 


参考:http://cb.esast.com/cb/wiki/22945

Installing Maven 3 on OS X


1. Install Mac Ports

2. Install Maven 3


Open a terminal and type the following:


sudo port install maven3 maven_select

sudo maven_select maven3



------------------------------------------------------------------------

使用MAVEN构造springside-4.0失败、异常


信息如下:

 

xxxx@localhost springside-4.0.0.RC3$ mvn install

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Build Order:

[INFO] 

[INFO] Springside :: Project

[INFO] Springside :: Module :: Core

[INFO] Springside :: Module :: Extension

[INFO] Springside :: Example :: Mini-Service

[INFO] Springside :: Example :: Mini-Web

[INFO] Springside :: Example :: Showcase

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Springside :: Project 4.0.0.RC3

[INFO] ------------------------------------------------------------------------

Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3.1/maven-install-plugin-2.3.1.pom

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary:

[INFO] 

[INFO] Springside :: Project ............................. FAILURE [1:15.947s]

[INFO] Springside :: Module :: Core ...................... SKIPPED

[INFO] Springside :: Module :: Extension ................. SKIPPED

[INFO] Springside :: Example :: Mini-Service ............. SKIPPED

[INFO] Springside :: Example :: Mini-Web ................. SKIPPED

[INFO] Springside :: Example :: Showcase ................. SKIPPED

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1:16.465s

[INFO] Finished at: Sun Jul 08 16:31:26 CST 2012

[INFO] Final Memory: 3M/81M

[INFO] ------------------------------------------------------------------------

[ERROR] Plugin org.apache.maven.plugins:maven-install-plugin:2.3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1: Could not transfer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.3.1 from/to central (http://repo1.maven.org/maven2): Error transferring file: Operation timed out -> [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




原因:

发现无法访问中央库http://repo1.maven.org/maven2/ 。


解决:过了两天就能访问了。

分享到:
评论
1 楼 田小川 2016-07-01  
mac 安装 maven 已经安装了xcode。帮忙看看什么问题。
1.配置环境变量如下
# maven所在的目录  
export PATH=/Users/documents/projectTools/apache-maven-3.3.9/bin:$PATH
2.用的是系统自带的JDK
CafeMacBook-Pro:~ Cafe$ java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
3.操作过程
3.1 下载了apache-maven-3.3.9 解压到了/Users/documents/projectTools/apache-maven-3.3.9路径
3.2 使用vi ~/.bash_profile 命令编辑文件。添加1中提到的配置
3.3 保存完成关闭的时候提示这个不可编辑,强制保存并退出了。
3.4 source ~/.bash_profile 使用这个命令是文件生效
3.5 执行 mvn -v  提示command not found。
3.6 新开一个窗口之后也提示command not found
3.7 /Users/documents/projectTools/apache-maven-3.3.9/bin  下面有个mvn文件,双击之后提示:
======提示信息开始======
Last login: Fri Jul  1 14:21:09 on ttys000
CafeChuandeMacBook-Pro:~ Cafe$ /Users/Cafe/Documents/projectTools/apache-maven-3.3.9/bin/mvn ; exit;
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.102 s
[INFO] Finished at: 2016-07-01T14:26:46+08:00
[INFO] Final Memory: 5M/245M
[INFO] ------------------------------------------------------------------------
----提示信息结束-----
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/NoGoalSpecifiedException
logout

[进程已完成]
======提示结束======

相关推荐

Global site tag (gtag.js) - Google Analytics