转载:https://www.jianshu.com/p/fec733a8f8a2
1、安装wget命令
如果需要通过使用wget命令,直接通过网络下载maven安装包时,需要在linux系统中安装wget命令。
yum -y install wget
进入一个目录
cd /usr/local
创建一个文件夹
mkdir maven
下载maven的tar包
wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
解压tar包
tar -xvf apache-maven-3.5.2-bin.tar.gz
配置环境变量
//打开环境变量的配置文件
vim /etc/profile
//新增行MAVEN_HOME,等于号后面是maven解压的文件夹地址
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.2
//找到PATH行,追加
M
A
V
E
N
H
O
M
E
/
b
i
n
例
如
P
A
T
H
=
MAVEN_HOME/bin 例如 PATH=
MAVENHOME/bin例如PATH=JAVA_HOME/bin:
M
A
V
E
N
H
O
M
E
/
b
i
n
:
MAVEN_HOME/bin:
MAVENHOME/bin:PATH
//重新刷新配置文件
source /etc/profile
测试安装
mvn -version
配置maven的镜像仓库
vim conf/settings.xml
//安装地址
/path/to/local/repo
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
<mirror>
<id>nexus-aliyun</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
| server for that repository.
|–>
nexus-aliyun
*
Nexus aliyun
http://maven.aliyun.com/nexus/content/groups/public
alimaven-central
central
aliyun maven
http://maven.aliyun.com/nexus/content/repositories/central/
jboss-public-repository-group
central
JBoss Public Repository Group
http://repository.jboss.org/nexus/content/groups/public
alimaven
aliyun maven
http://maven.aliyun.com/nexus/content/groups/public/
central
mirrorId
repositoryId
Human Readable Name for this Mirror.
http://my.repository.com/repo/path
作者:葡小萄家的猫
链接:https://www.jianshu.com/p/fec733a8f8a2
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。