第一步:下载Apache-Maven安装包并更改设置文件
1.访问官网地址:http://maven.apache.org/index.html
如图示
2.点击左侧Download菜单
03.png
3.下载apache-maven-3.5.4-bin.zip
4.解压至E盘(可随意设定),路径为E:\apache-maven-3.5.4
5.打开E:\apache-maven-3.5.4\conf\settings.xml(建议设置)
【1】设定maven依赖的本地存储路径,主要是为了利于查找,原来的路径为:C:\Users\Administrator.m2\repository
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!--设置如下-->
<localRepository>E:/apache-maven-3.5.4/repository</localRepository>
【2】添加国内maven镜像
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of 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>
-->
<!--添加如下-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
第二步:配置Maven环境变量以及设置Eclipse中Maven的路径
1.鼠标右击【计算机】或【我的电脑】,点击属性->高级系统设置->环境变量->新建
M2_HOME=E:\apache-maven-3.5.4
同时设置在原来的Path路径下添加;%M2_HOME%\bin
maven配置
2.点击开始->运行->输入cmd->命令行输入mvn -version进行验证是否安装成功
3.打开Eclipse,依次点击Window->Preferences->Maven->User Settings,
并设置User Settings为E:\apache-maven-3.5.4\conf\settings.xml
至此,Maven的安装与配置就完成啦!接下来就可以创建Maven项目,感谢阅读,祝你好运!
网友评论