一、maven下载
下载前建议阅读:IDEA版本与MAVEN版本对应关系,及历史MAVEN版本下载
下载时bin/src的区别:https://blog.youkuaiyun.com/weixin_43983383/article/details/128400832
二、maven配置
1、环境变量配置(两种方式二选一)
① 用户变量+ 系统环境变量配置
② 系统环境变量直接配置 bin文件位置。
注意:Win 10系统按照方式一配置后会出现命令不存在问题,方式二可解决。
2、配置文件配置:
配置文件示例地址:D:\maven\apache-maven-3.9.0\conf\settings
① maven本地仓库配置
<localRepository>D:\maven\mvnrepository</localRepository>
② maven 远程仓库配置
<!-- 注释默认的中央仓库 -->
<!-- <mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror> -->
<!-- 配置国内阿里云镜像 -->
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
3、IDEA中配置
File——》setting——》直接搜索框搜索 maven
注:图中说明的“一般settings配置后会默认识别本地仓库位置”,指的是指定配置文件后,并非修改settings.xml文件后,但需要自动识别自定义本地仓库位置,则前提是需要修改settings.xml文件后。
三、验证安装
Win + R 输入cmd,下面三条命令三选一验证即可,提示maven信息则安装成功。
四、中央仓库
扩展-后期补充:
1、maven是什么?
是Java项目中的依赖包管理,通过g(group-组别)a(artifactId-唯一Id)v(version-版本)定位依赖包坐标。
还可以通过命令或IDEA中集成的工具进行依赖包管理。
2、maven项目
3、maven配置多镜像地址
4、maven配置jdk
在MAVEN安装目录的config文件夹打开settings.xml文件,在标签中添加:
<code class="language-plaintext hljs"><profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile></code>