Orw*_*erg 44 linux redhat yum maven
注意:最初发布时我试图安装maven2.由于主要答案是maven3,我更新了标题.问题的其余部分仍然是最初发布的.
我正在尝试使用该命令在redhat linux机器上安装maven2
yum install maven2
Run Code Online (Sandbox Code Playgroud)
但是yum似乎无法找到maven2.
No package maven2 available
Run Code Online (Sandbox Code Playgroud)
我有关于此主题的其他帖子,但以下帖子的答案建议添加回购.我添加了所述回购,但添加后会遇到错误.
如何将Maven安装到Red Hat Enterprise Linux 6中?
我只能通过命令行访问此框,因此从我们的网站上下载maven对我来说很困难.
Ica*_*rus 91
转到mirror.olnevhost.net/pub/apache/maven/binaries/并查看最新的tar.gz文件是什么
假设它是例如apache-maven-3.2.1-bin.tar.gz,来自命令行; 你应该能够做到:
wget http://mirror.olnevhost.net/pub/apache/maven/binaries/apache-maven-3.2.1-bin.tar.gz
Run Code Online (Sandbox Code Playgroud)
然后继续安装它.
更新:添加完整说明(从下面的评论中复制)
运行以下命令来提取tar:
tar xvf apache-maven-3.2.1-bin.tar.gz
Run Code Online (Sandbox Code Playgroud)接下来添加env varibles,例如
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.1
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
校验
mvn -version
Run Code Online (Sandbox Code Playgroud)我做了以下脚本:
#!/bin/bash
# Target installation location
MAVEN_HOME="/your/path/here"
# Link to binary tar.gz archive
# See https://maven.apache.org/download.cgi?html_a_name#Files
MAVEN_BINARY_TAR_GZ_ARCHIVE="http://www.trieuvan.com/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz"
# Configuration parameters used to start up the JVM running Maven, i.e. "-Xms256m -Xmx512m"
# See https://maven.apache.org/configure.html
MAVEN_OPTS="" # Optional (not needed)
if [[ ! -d $MAVEN_HOME ]]; then
# Create nonexistent subdirectories recursively
mkdir -p $MAVEN_HOME
# Curl location of tar.gz archive & extract without first directory
curl -L $MAVEN_BINARY_TAR_GZ_ARCHIVE | tar -xzf - -C $MAVEN_HOME --strip 1
# Creating a symbolic/soft link to Maven in the primary directory of executable commands on the system
ln -s $MAVEN_HOME/bin/mvn /usr/bin/mvn
# Permanently set environmental variable (if not null)
if [[ -n $MAVEN_OPTS ]]; then
echo "export MAVEN_OPTS=$MAVEN_OPTS" >> ~/.bashrc
fi
# Using MAVEN_HOME, MVN_HOME, or M2 as your env var is irrelevant, what counts
# is your $PATH environment.
# See http://stackoverflow.com/questions/26609922/maven-home-mvn-home-or-m2-home
echo "export PATH=$MAVEN_HOME/bin:$PATH" >> ~/.bashrc
else
# Do nothing if target installation directory already exists
echo "'$MAVEN_HOME' already exists, please uninstall existing maven first."
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93400 次 |
| 最近记录: |