Maven下载
- Maven官网:https://maven.apache.org/
以maven 3.6.3为例,下载方式如下
配置
下载后解压,解压目录如下,在目录中新建 repository 文件夹
新建系统变量 MAVEN_HOME 变量值为 Maven解压包路径
在Path系统变量中添加 %MAVEN_HOME%\bin
验证
Win+R运行cmd,输入mav -v进行验证
配置文件
在Maven目录中找到config文件夹下的settings.xml文件
- 添加repository文件夹路径
解除localRepository标签,将repository文件夹路径添加进去,如下图所示,repository文件夹是maven远程下载依赖包存放的位置
- 配置maven镜像地址
在mirrors标签中添加如下代码
<!-- 阿里云仓库 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror>
<span class="token comment"><!-- 中央仓库1 --></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mirror</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>id</span><span class="token punctuation">></span></span>repo1<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>id</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>mirrorOf</span><span class="token punctuation">></span></span>central<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mirrorOf</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>name</span><span class="token punctuation">></span></span>Human Readable Name for this Mirror.<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>name</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>url</span><span class="token punctuation">></span></span>https://repo1.maven.org/maven2/<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>url</span><span class="token punctuation">></span></span> <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>mirror</span><span class="token punctuation">></span></span>
IDEA全局配置
- 配置Maven路径、配置文件路径和本地仓库路径
关闭IDEA全部工程项目,找到左侧maven,不要勾选work offline,配置路径如下图所示
- 配置Importing
配置https访问获取依赖包的免SSL认证,以便于远程导入依赖包,命令如下
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
到此,Maven配置成功