maven安装

来源:互联网 发布:云盘推荐 知乎 编辑:程序博客网 时间:2024/06/12 01:12

1.下载并加压maven

2.配置环境变量(M2_HOME.Path)

   拷贝路径(D:\maven\apache-maven-3.2.3),新建环境变量名为M2_HOME,值为拷贝路径。

   编辑Path将,%M2_HOME%\bin;添加到Path中,点击确定。

   测试一下,打开cmd,输入命令mvn -version回车,出现maven版本信息等则安装成功。

3.配置maven配置文件(本地仓库路径,镜像)

   找到解压路径下的conf的目录,进入目录,找到settings.xml文件,将文件拷贝到C:\Users\Administrator\.m2目录下,打开settings.xml,找到 如下两个地方:

1.<!-- 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\repo</localRepository><!-- 自定义maven仓库的位置,如果不设置那么默认存储在${user.home}/.m2/repository下 -->

2. <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>UK</id>
          <name>UK Central</name>
          <url>http://uk.maven.org/maven2</url>
          <mirrorOf>central</mirrorOf>
         </mirror>
  </mirrors>

这样maven就安装好了。




0 0