安装Git环境
yum install -y git
1、安装wget命令
yum -y install wget
2、下载maven安装包
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
3、解压缩maven
tar -zxvf apache-maven-3.5.4-bin.tar.gz
4、配置maven环境变量
vi /etc/profile
添加环境变量
export MAVEN_HOME=/usr/local/pid/apache-maven-3.6.2
export MAVEN_HOME
export PATH=$PATH:$MAVEN_HOME/bin
编辑之后记得使用source /etc/profile命令是改动生效。
5、验证结果
mvn -version
在任意路径下执行 验证命令是否有效。正常结果如下,能够看到当前maven及jdk版本。
可选:需要配置maven仓库
创建一个maven仓库储存jar包地址
[root@worker apache-maven-3.6.2]# mkdir repository
配置maven,进入 /mnt/data/odc/apache-maven-3.6.2/conf 目录下
[root@worker conf]# vim settings.xml
#修改如下配置
#1、配置仓库地址
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>/mnt/data/odc/apache-maven-3.6.2/repository</localRepository>
#2、配置阿里云镜像
<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>
end
网友评论