Maven下载与安装

1.下载文件

     下载地址:http://maven.apache.org/download.cgi,zip

2.解压压缩包 apache-maven-3.6.3-bin.zip

3.配置环境变量

将M2_HOME追加到path环境变量中

4.cmd ---> mvn -version 出现以下,表示安装成功

5.在cmd下 执行 mvn help:system 命令,下载配置到本地仓库(.m2 / settings.xml)

详见:http://maven.apache.org/settings.html

settings.xml文件可能存在两个位置:

  • Maven安装:$ {maven.home} /conf/settings.xml
  • 用户的安装:$ {user.home} /.m2 / settings.xml

前一个settings.xml也称为全局设置,后一个settings.xml称为用户设置。如果两个文件都存在,则它们的内容将合并,其中用户特定的settings.xml是主要文件。

提示:如果需要从头开始创建用户特定的设置,则最简单的方法是将全局设置从Maven安装复制到$ {user.home} /。m2目录。Maven的默认settings.xml是带有注释和示例的模板,因此您可以快速对其进行调整以满足您的需求。

也可自定义本地仓库路径,修改settings.xml文件中localRepository标签

<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
   -->
  <localRepository>E:\repository</localRepository> 即可。

6.添加中央仓库

 <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.
     |-->
	 <!-- aliyun -->
    <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public/</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>
  </mirrors>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值