Java|--Linux 安装Maven

前提 : 安装位置选择 / JDK已经安装

/usr/local/

备注 : Linux直接将安装压缩包解压后,
有点像Windows系统的绿色安装一样.

0.下载 >> 解压 >> 移动

下载页面→官方下载页面 - https://maven.apache.org/download.cgi

wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz --no-check-certificate
#解压
tar -zxvf apache-maven-3.8.4-bin.tar.gz
#从临时目录移至/usr/local/下
cp -r apache-maven-3.8.4 /usr/local/
#进入apache-maven-3.8.4目录
cd /usr/local/apache-maven-3.8.4/
#创建ck目录
mkdir ck

1.编辑settings.xml

进入cd conf目录,编辑 vi settings.xml文件,找到·localRepository下面复制一行加上/usr/local/apache-maven-3.8.4/ck

cd conf/
vim conf/settings.xml
<!-- localRepository -->
<localRepository>/usr/local/apache-maven-3.8.4/ck</localRepository>

<!-- mirror -->
<mirror>  
	<id>alimaven</id>  	
	<name>aliyun maven</name>  
	<mirrorOf>central</mirrorOf>
	<url>http://maven.aliyun.com/nexus/content/groups/public</url>  
</mirror> 

Java|--Linux 安装Maven

Java|--Linux 安装Maven

2.配置maven环境变量,

编辑:vi /etc/profile 文件,翻到最后一行加上
export MAVEN_HOME=/usr/local/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin
保存退出

vim /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin

3.重新加载一下/etc/profile

执行source /etc/profile 使新增配置生效,如下:

source /etc/profile
mvn -v
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

4.验证安装是否成功

mvn --version
#输出...↓
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /usr/local/apache-maven-3.8.4
Java version: 1.8.0_311, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8.0_311/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.31.1.el7.x86_64", arch: "amd64", family: "unix"

上一篇:在Apache服务器上执行Python CGI脚本的配置方法


下一篇:前后端代码部署,安装mysql、apache-tomcat