一、安装Maven
安装路径:点击链接进去直接下载所需的版本Maven官网
一、最新版本下载方式
1、点击链接进入Maven官网
2、找到左侧栏的Download找到Files下载即可
二、所有版本的下载方式(里面新老版本都有)
1、点击链接进入Maven官网
2、找到左侧栏的Download
3、查看图二中箭头所指向的archives点击进去里面有所有的版本
4、找到需要的版本号进行对应下载
二、Maven的配置教程来咯
1、在官网下载完Maven后,放在自己修改的路径下,将压缩包解压
2、解压完毕后,配置path环境变量
找到系统变量的方式:
3、 此电脑 —>右击找到属性—>右击选中高级系统设置—>系统属性下找到环境变量进行配置系统变量
配置填写(系统变量路径不能错,path编辑的格式不要错哦):
系统变量:MAVEN_HOME = E:\Learn\Maven\apache-maven-3.5.4
系统变量:path = %MAVEN_HOME%\bin
具体操作如图所见
Maven_Home✔:
Path✔:
三、完成以上步骤之后进行测试,看Maven是否安装成功
输入命令 mvn -version,测试成功如下图
四、配置setting.xml文件
1、在E:\Learn\Maven\apache-maven-3.5.4\conf下可以找到settings文件
2、找到第55行,这里是maven默认的仓库(在解压的路径下面去添加一个空的repo文件)
<localRepository>E:\Learn\Maven\apache-maven-3.5.4\repo</localRepository>
3、55行设置的repo路径之后变成默认选中这个路径
4、因为国外的服务器下载jar包很慢所以我们改为阿里云服务器(大约在150行左右),这两个仓库只用选一个(根据大家反馈建议使用第一个,第二个在有的版本可能会出现warning)
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
或者
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
5、如何所示操作,需要放在mirrors中间,不可随意乱放
6、最后配置jdk,也要夹在两个profiles标签之间(我这里使用的为jdk8)
7、配置完成,在命令行输入mvn help:system测试,看到下载链接里面是ailiyun的链接表示配置成功
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${
user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings