maven 官网地址:https://maven.apache.org/download.cgi
安装包下载地址:https://dlcdn.apache.org/maven/maven-3
这里下载 apache-maven-3.3.9-bin.tar.gz
下载后上传到Linux服务器
解压 maven 安装包到 maven 文件夹:
$ mkdir -p /home/zhangshixing/maven
$ tar -zxvf apache-maven-3.3.9-bin.tar.gz -C /home/zhangshixing/maven
创建 maven 资源库目录:
$ mkdir -p /home/zhangshixing/maven/m2/repository
编辑 settings.xml 文件:
$ cd /home/zhangshixing/maven/apache-maven-3.3.9/conf/
$ vim settings.xml
将原文件内容全部删除,添加新的配置内容,删除命令:
:1,.d
新的配置内容,修改了资源库位置,添加了阿里云国内镜像:
<settings
xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<localRepository>/home/zhangshixing/maven/m2/repositorylocalRepository>
<pluginGroups>pluginGroups>
<proxies>proxies>
<servers>servers>
<mirrors>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
mirrors>
<profiles>profiles>
settings>
vim /etc/profile
添加 maven 环境变量内容
MAVEN_HOME=/home/zhangshixing/maven/apache-maven-3.3.9
PATH=$MAVEN_HOME/bin:$PATH
export MAVEN_HOME PATH
重新加载配置文件
source /etc/profile
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /home/zhangshixing/maven/apache-maven-3.3.9
Java version: 11.0.17, vendor: Red Hat, Inc.
Java home: /usr/lib/jvm/java-11-openjdk-11.0.17.0.8-2.el7_9.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.80.1.el7.x86_64", arch: "amd64", family: "unix"
安装包下载地址:https://dlcdn.apache.org/maven/maven-3
这里下载 apache-maven-3.3.9-bin.zip
下载安装包之后将安装包解压到 D:\DecompressionSoftwareInstall
目录。
解压之后的目录:D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin
新建仓库目录:D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin\repository
修改 D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin\conf\settings.xml
配置文件:
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin\repositorylocalRepository>
<pluginGroups>pluginGroups>
<proxies>proxies>
<servers>servers>
<mirrors>
<mirror>
<id>alimavenid>
<mirrorOf>centralmirrorOf>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/repositories/central/url>
mirror>
mirrors>
<profiles>
<profile>
<id>jdk-1.8id>
<activation>
<activeByDefault>trueactiveByDefault>
<jdk>1.8jdk>
activation>
<properties>
<maven.compiler.source>1.8maven.compiler.source>
<maven.compiler.target>1.8maven.compiler.target>
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
properties>
profile>
profiles>
settings>
配置环境变量:
M2_HOME = D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin
$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: D:\DecompressionSoftwareInstall\apache-maven-3.3.9-bin
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: D:\OwnerSoftwareInstall\jdk\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"