如何在Redhat Linux上安装Maven [英] How to install maven on redhat linux
问题描述
注意:最初发布时,我正在尝试安装maven2.由于主要答案是针对maven3的,因此我更新了标题.问题的其余部分仍然保持原来的状态.
Note: When originally posted I was trying to install maven2. Since the main answer is for maven3 I have updated the title. The rest of the question remains as it was originally posted.
我正在尝试使用命令在Redhat linux盒子上安装maven2
I'm trying to install maven2 on a redhat linux box using the command
yum install maven2
但是yum似乎无法找到maven2.
but yum doesn't seem to be able to find maven2.
No package maven2 available
我遇到过有关该主题的其他帖子,但以下帖子的答案建议添加存储库.我添加了上述存储库,但添加后遇到了错误.
I've run across other posts about this topic, but the answer to the following post suggests to add repos. I add said repos, but run into errors after adding them.
我只能通过命令行访问此框,因此对我来说很难从他们的网站上下载maven.
I can only access this box via command line so simply downloading maven from their website is difficult for me.
推荐答案
转到镜像.olnevhost.net/pub/apache/maven/binaries/并检查什么是最新的tar.gz文件
Go to mirror.olnevhost.net/pub/apache/maven/binaries/ and check what is the latest tar.gz file
假设它是apache-maven-3.2.1-bin.tar.gz,从命令行;您应该可以轻松做到:
Supposing it is e.g. apache-maven-3.2.1-bin.tar.gz, from the command line; you should be able to simply do:
wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.2.1-bin.tar.gz
然后继续安装它.
更新:添加完整的说明(从下面的注释中复制)
UPDATE: Adding complete instructions (copied from the comment below)
- 从要提取Maven的目录中运行上述命令(例如/usr/local/apache-maven)
-
运行以下命令以提取tar:
- Run command above from the dir you want to extract maven to (e.g. /usr/local/apache-maven)
run the following to extract the tar:
tar xvf apache-maven-3.2.1-bin.tar.gz
接下来添加env变量,例如
Next add the env varibles such as
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.1
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
验证
mvn -version
这篇关于如何在Redhat Linux上安装Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!