CentOS 7.9 源码编译安装maven
Centos镜像源中没有maven,通过下载源码编译进行安装:
shell
# 下载
$ wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz --no-check-certificate
$ tar xf apache-maven-3.9.6-bin.tar.gz
$ sudo mv apache-maven-3.9.6/ /usr/local/
# 配置环境变量
$ sudo vim /etc/profile # 增加如下配置
export MAVEN_HOME=/usr/local/apache-maven-3.9.6
export PATH=$MAVEN_HOME/bin:$PATH
# 配置生效
$ source /etc/profile
# 检查版本
$ mvn -version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /usr/local/apache-maven-3.9.6
Java version: 1.8.0_402, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.402.b06-1.el7_9.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.21.1.el7.x86_64", arch: "amd64", family: "unix"
# 配置镜像加速+指定仓库地址
/usr/local/apache-maven-3.9.6/conf/settings.xml
# 配置jar包下载路径
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/home/maven/repo</localRepository>
-->