8

Can anyone help me installing maven 3.0.5 in linux please?

I tried using wget, yum and tar command. All the commands are saying its not recognized as an external or internal command and now I am blank as to how to achieve it. Do we need to go to start->cmd and apply these commands??

And also please tell me how to set the environment variable. Please help me.

Thanks in advance.

4

3 回答 3

35

我们需要做的第一件事是下载 Maven tar 文件并将其解压缩到工作站上的共享位置

wget http://mirrors.gigenet.com/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
su -c "tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/" 

在共享配置文件中设置 Maven 环境变量。下一步是在共享配置文件中设置 Maven 环境变量,以便系统上的所有用户在登录时将它们导入。

su -c "vi /etc/profile.d/maven.sh"

# Add the following lines to maven.sh
export M2_HOME=/opt/apache-maven-3.0.5
export M2=$M2_HOME/bin
PATH=$M2:$PATH 

现在测试您的 Maven 安装。注销系统,然后重新登录。输入以下命令:

[jsmith@regan ~]$ mvn -version 

如果您做对了所有事情,您的输出应该如下所示:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /opt/apache-maven-3.0.5
Java version: 1.7.0_19, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-358.2.1.el6.i686", arch: "i386", family: "unix"
于 2013-07-22T11:35:08.463 回答
3

上面的链接失效了,它已经损坏了,如果你想要最新版本,请找到下面的链接: wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.0.5-bin.tar.gz

脚步:

  1. 下载文件在/opt/Maven/apache-maven-3.0.5-bin.tar.gz
  2. 在相同位置提取文件tar xvf apache-maven-3.0.5-bin.tar.gz并运行。
  3. 打开vi /etc/profile
  4. 粘贴这些行:

    导出 M2_HOME=/opt/Maven/apache-maven-3.0.5

    导出 PATH=$PATH:$M2_HOME/bin

  5. 保存文件。

  6. source /etc/profile
  7. 最后运行mvn -version,您将获得 maven 版本

Maven安装完成。

于 2014-07-09T06:25:46.693 回答
0
echo $JAVA_HOME if returns empty(export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home)
echo $PATH if returns empty(export PATH=$PATH:$JAVA_HOME/bin)
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
mvn --version
ALL SET *******

In case if this doesn't work after this step,

vi .profile
export PATH={$PATH}:'/usr/local/apache-maven/apache-maven-3.2.3/bin/
于 2014-12-09T19:44:18.263 回答