1.下载maven

网址:http://maven.apache.org

apache-maven安装-LMLPHP

2.下载maven和安装

apache-maven安装-LMLPHP

由于最新版的可能会有问题,我选择下载旧版本

apache-maven安装-LMLPHP

一般都下载二进制的zip文件

apache-maven安装-LMLPHP

apache-maven安装-LMLPHP

apache-maven安装-LMLPHP

解压后文件夹apache-maven-3.6.1,打开设置系统环境变量配置

添加MAVEN_HOME和path

MAVEN_HOME中变量值为maven所在的目录

apache-maven安装-LMLPHP

apache-maven安装-LMLPHP

添加环境变量M2_HOME值为maven的bin目录

apache-maven安装-LMLPHP

测试是否成功

命令行输入: mvn -v

apache-maven安装-LMLPHP

3.设置阿里镜像加快下载

根据自己情况而定找到 C:\Users\DELL\.m2  (用户里面的.m2文件夹)中的settings.xml 如果没有则自己建立一个文件为settings.xml的

 <?xml version="1.0" encoding="UTF-8"?>
<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"> <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>
</mirrors> </settings>

修改镜像

 <!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror> <!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror> <!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>

在idea开始界面配置maven的工具以及settings.xml和repository地址即可。

4.查找jar包网址:https://mvnrepository.com/

apache-maven安装-LMLPHP

搜索servlet-api:

apache-maven安装-LMLPHP

apache-maven安装-LMLPHP

 <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>

红色区域就是可以导入的依赖了。

05-27 21:39