centos install maven

1、获取安装包并解压

1
2
3
4
cd /usr/local
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

tar -zxvf apache-maven-3.6.3-bin.tar.gz

2、配置环境变量,添加export

1
vim /etc/profile
1
2
export MAVEN_HOME=/usr/local/maven
export PATH=${MAVEN_HOME}/bin:${PATH}
1
source /etc/profile
1
mvn -v
1
2
vim ~/.bash_profile
JAVA_HOME 和 M2_HOME 都设置成自己文件的位置
1
source ~/.bash_profile

3、添加阿里云镜像

1
vim $MAVEN_HOME/conf/settings.xm

添加以下镜像配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>central-repository</id>
<mirrorOf>*</mirrorOf>
<name>Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</mirror>

</mirrors>

评论