下载maven
解压
tar -xzvf apache-maven-3.0.5-bin.tar.gz
配置环境变量
sudo vim /etc/profile
添加
export M2_HOME=/home/weibo/apache-maven-3.0.5
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
保存
source profile
测试
mvn -version
公司的maven还需要配置settings.xml(maven包的conf里的settings.xml可不用管)
把附件中的文件放到存放类库的位置(一般是{user.dir}/.m2/里)
注意更改其中的<localRepository>的值
<?xml version="1.0"?>
<!-- ======================================================================== -->
<!-- settings.xml for maven users -->
<!-- Version: 3 -->
<!-- Auhtor: jingshun shi -->
<!-- $Id: settings.xml 220145 2012-11-23 01:41:14Z jingshun.shijs $ -->
<!-- ======================================================================== -->
<settings>
<!-- ======================================================================== -->
<!-- Accounts for SCM ONLY -->
<!-- ======================================================================== -->
<localRepository>D:\m2\repo</localRepository>
<servers>
<server>
<id>releases</id>
<username>maven</username>
<password>secret</password>
</server>
<server>
<id>snapshots</id>
<username>maven</username>
<password>secret</password>
</server>
</servers>
<!-- ======================================================================== -->
<!-- Profiles -->
<!-- ======================================================================== -->
<profiles>
<profile>
<!-- ======================================================================== -->
<!-- Managed Repositories for Alibaba Dev,include tabao repos and center repo-->
<!-- ======================================================================== -->
<id>alibaba</id>
<repositories>
<repository>
<id>central</id>
<name>Alibaba Repositories Group</name>
<url>http://repo.alibaba-inc.com/nexus/content/groups/alirepositiry/</url>
</repository>
<repository>
<id>pwatir</id>
<url>http://maven.pwatir.com/artifactory/repo/</url>
</repository>
</repositories>
<!-- ======================================================================== -->
<!-- Repositories for maven plugins -->
<!-- ======================================================================== -->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Alibaba Plugin Repos Group</name>
<url>http://repo.alibaba-inc.com/nexus/content/groups/alirepositiry/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>android</id>
<properties>
<android.sdk.path>
D:\android_ide\sdk <!-- 此处为自己sdk路径 -->
</android.sdk.path>
</properties>
</profile>
</profiles>
<pluginGroups>
<pluginGroup>com.alibaba.org.apache.maven.plugins</pluginGroup>
<pluginGroup>com.alibaba.maven.plugins</pluginGroup>
</pluginGroups>
<activeProfiles>
<activeProfile>alibaba</activeProfile>
<activeProfile>android</activeProfile>
</activeProfiles>
</settings>
<!-- ======================================================================== -->
<!-- settings.xml for maven users -->
<!-- Version: 3 -->
<!-- Auhtor: jingshun shi -->
<!-- $Id: settings.xml 220145 2012-11-23 01:41:14Z jingshun.shijs $ -->
<!-- ======================================================================== -->
<settings>
<!-- ======================================================================== -->
<!-- Accounts for SCM ONLY -->
<!-- ======================================================================== -->
<localRepository>D:\m2\repo</localRepository>
<servers>
<server>
<id>releases</id>
<username>maven</username>
<password>secret</password>
</server>
<server>
<id>snapshots</id>
<username>maven</username>
<password>secret</password>
</server>
</servers>
<!-- ======================================================================== -->
<!-- Profiles -->
<!-- ======================================================================== -->
<profiles>
<profile>
<!-- ======================================================================== -->
<!-- Managed Repositories for Alibaba Dev,include tabao repos and center repo-->
<!-- ======================================================================== -->
<id>alibaba</id>
<repositories>
<repository>
<id>central</id>
<name>Alibaba Repositories Group</name>
<url>http://repo.alibaba-inc.com/nexus/content/groups/alirepositiry/</url>
</repository>
<repository>
<id>pwatir</id>
<url>http://maven.pwatir.com/artifactory/repo/</url>
</repository>
</repositories>
<!-- ======================================================================== -->
<!-- Repositories for maven plugins -->
<!-- ======================================================================== -->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Alibaba Plugin Repos Group</name>
<url>http://repo.alibaba-inc.com/nexus/content/groups/alirepositiry/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>android</id>
<properties>
<android.sdk.path>
D:\android_ide\sdk <!-- 此处为自己sdk路径 -->
</android.sdk.path>
</properties>
</profile>
</profiles>
<pluginGroups>
<pluginGroup>com.alibaba.org.apache.maven.plugins</pluginGroup>
<pluginGroup>com.alibaba.maven.plugins</pluginGroup>
</pluginGroups>
<activeProfiles>
<activeProfile>alibaba</activeProfile>
<activeProfile>android</activeProfile>
</activeProfiles>
</settings>