云安装
yum -y install apache-maven
如果没有下载下来就先更新下资源包,再重试
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
编辑文件/opt/maven/apache-maven-3.6.1/conf/settings.xml
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
配置环境变量,编辑文件/etc/profile
在最下面添加以下内容(MAVEN_HOME是刚才解压maven的路径)
MAVEN_HOME=/opt/maven/apache-maven-3.6.1
export PATH=$MAVEN_HOME/bin:$PATH
刷新环境变量
source /etc/profile
到此安装完成,可以看到maven信息说明安装成功
[root@maruifu maven]# mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /opt/maven/apache-maven-3.6.1
Java version: 1.8.0_141, vendor: Oracle Corporation, runtime: /usr/local/java/jdk1.8/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.21.3.el7.x86_64", arch: "amd64", family: "unix"