Maven 安装与配置
maven 搜索jar包: https://mvnrepository.com/
一、安装
前提:已经安装配置 JDK
1)进入官网下载链接 http://maven.apache.org/download.cgi
选择 版本 (Windows -> binary zip; Linux -> binary tar.gz)
2)解压
解压后,将文件夹复制到要保存的目录,如 D:\Program Files (x86)\ 下
二、配置环境变量
1)新建环境变量 MAVEN_HOME,值是 刚才保存的目录 D:\Program Files (x86)\apache-maven-3.6.3
2)%MAVEN_HOME%\bin\ 添加 到 PATH 环境变量下
3)查看是否安装完成,cmd 下运行“mvn -v”
三、配置 Maven 本地仓库
1)目录 D:\Program Files (x86)\apache-maven-3.6.3\ 下,新建 repository 文件夹,或其他地方
2)D:\Program Files (x86)\apache-maven-3.6.3\conf\settings.xml,修改,将 localRepository 复制出来,然后将本地路径,填入
注:如果不修改,默认将放置 在 ${user.home}/.m2/repository
3)配置 mirror,作用可以从配置的mirror的地方下载
找到 setting.xml 的 mirrors, 修改如下配置
<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>nexus-aliyun</id> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <!-- 剩下就是国外的了,maven官方运维的2号仓库 --> <!-- <mirror> <id>repo2</id> <name>Mirror from Maven Repo2</name> <url>http://repo2.maven.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> --> <!-- maven在UK架设的仓库(有时候速度会比官方2号仓库快) --> <!-- <mirror> <id>ui</id> <name>Mirror from UK</name> <url>http://uk.maven.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> --> <!-- JBoss的仓库 --> <!-- <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> --> </mirrors>