1、首先下载maven,地址为:http://maven.apache.org/download.cgi,如下图所示:
2、然后将解压到某个目录,入下图所示:
3、配置环境变量,添加一个:MAVEN_HOME,值为:D:\InstallFile\maven,如下图所示:
4、然后在path中加入:%MAVEN_HOME%\bin,入下图所示:
5、然后打开dos窗口输入mvn -version验证,如下图所示:
6、修改mvn仓库下载位置,找到maven目录下的conf,然后有一个settings.xml文件,如下图所示:
7、打开settings.xml文件找到localRepository,然后加入仓库路径即可,入下图所示:
8、保存退出,然后在maven中创建一个repo文件夹,入下图所示:
9、然后在setting.xml配置成国内镜像可以下载的很快,只需要在:mirrors中加入如下信息:
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>net-cn</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.net.cn/content/groups/public/</url>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>JBossJBPM</id>
<mirrorOf>central</mirrorOf>
<name>JBossJBPM Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</mirror>
<mirror>
<id>antelink</id>
<mirrorOf>central</mirrorOf>
<name>antelink Repository</name>
<url>http://maven.antelink.com/content/repositories/central/</url>
</mirror>
<mirror>
<id>openkoala</id>
<mirrorOf>central</mirrorOf>
<name>openkoala Repository</name>
<url>http://nexus.openkoala.org/nexus/content/groups/Koala-release/</url>
</mirror>
<mirror>
<id>tmatesoft</id>
<mirrorOf>central</mirrorOf>
<name>tmatesoft Repository</name>
<url>http://maven.tmatesoft.com/content/groups/public/</url>
</mirror>
<mirror>
<id>mavensync</id>
<mirrorOf>central</mirrorOf>
<name>mavensync Repository</name>
<url>http://mavensync.zkoss.org/maven2/</url>
</mirror>
如下图所示:
10、然后将setting.xml拷贝到该目录即可,入下图所示:
注意:使用mvn package打包使用的setting.xml和在pom.xml配置的不是使用的同一个setting.xml文件,因此在maven目录和其他的位置都要统一修改,在mac上通过brew安装的目录位置在/usr/local/Cellar/maven/3.6.0/libexec/conf中