Maven安装使用指南.md 1.6 KB

下载

参考:

下载 apache-maven-3.x.x-bin.zip

安装

  1. 解压

  2. 追加环境变量path

;MAVEN_HOME/bin

不用再设置 M2_HOME 或 MAVEN_HOME 了

  1. CMD命令行下 mvn -v 测试

使用

无网络下使用 Maven

  1. 本地仓库一定要存在需要的jar包

  2. 设置本地仓库

   <settings>
   	...
       <localRepository>E:\wokesoftware\maven-repository</localRepository>
       ...
   </settings>
  1. 把镜像地址指向本地仓库
   <settings>
   	...
       <mirrors>
           <mirror>
               <id>central</id>
               <name>central</name>
               <!-- 将镜像地址设置为本地maven地址 -->
               <url>file://E:\wokesoftware\maven-repository</url>
               <mirrorOf>*</mirrorOf>
           </mirror>
       </mirrors>
       ...
   </settings>

常见问题:

Failure to transfer $groupId:$artifactId:pom:$version from $centralUrl was cached in the local repository, resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced。Original error: Could not transfer artifact $groupId:$artifactId:pom:$version from/to central ($centralUrl):repo.maven.apache.org

解决方案:有可能就是联网的问题