Maven配置教程

​​​​​1.什么是maven

Apache Maven是一个软件项目管理和理解工具。基于项目对象模型(POM)的概念,Maven可以从一条中心信息中管理项目的构建,报告和文档

就是项目管理工具(使用maven必须要有Java的开发环境 JAVA-home环境变量)

2.下载Maven

Maven 下载地址:Maven – Download Apache Mavenicon-default.png?t=M5H6http://maven.apache.org/download.cgi

(1)Maven目录是什么意思

bin: 包含了Maven的运行脚本(mvn.cmd)

boot:类的加载器框架(Maven是由java开发的)

conf:是Maven工具的核心配置文件settings.xml

lib:含有Maven运行是需要的Java的jar包  需要JAVA-HONE的环境变量

(2)本地配置maven

先检查有没有JAVA-HONE的环境变量     运行cmd  输入echo%java_home%进行查看

 配置Maven的环境变量   M2_HOME(个人推荐使用  兼容了老版本)和

MAVEN_HOME(maven3之后)

 

然后在path里面添加

 (3)检查一下是否配置成功   在cmd里输入 mvn          -version

 (4)配置Maven的镜像

Maven是项目管理工具   就是管理jar包的     Maven是外国发明的,在国外提供了下载jar包的中央仓库,并且下载的jar包在c盘。

中央仓库在国外

提高下载速度 ,把下载位置改到阿里云

位置:conf/settings.xml文件

<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>

(5)设置本地仓库

从中央仓库下载的jar包保存在本地     conf/settings.xml

先建立本地文件夹 D:\maven-repository

<localRepository>D:\maven-repository</localRepository>

<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">
<!--  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>D:\maven-repository</localRepository>
<!--  interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
   -->

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值