基础环境配置
1. 在apache maven 下载 指定版本的maven压缩包
2. 将文件解压到指定目录下: D:\Java\apache-maven-3.8.1
3. 配置maven的环境变量:
- 新建一个
MAVEN_HOME
的环境变量,变量值就是第二步解压的文件目录D:\Java\apache-maven-3.8.1
在Path变量中添加
%MAVEN_HOME%\bin
4.测试是否配置成功,在cmd窗口中输入mvn -v
4.测试是否配置成功,在cmd窗口中输入mvn -v
C:\Users\Administrator>mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: D:\Java\apache-maven-3.8.1\bin\..
Java version: 1.8.0_77, vendor: Oracle Corporation, runtime: D:\Java\jdk1.8.0_77\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
5.配置setting.xml,更改maven的相关配置 :
<!-- 配置本地仓库地址 -->
<!-- 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 标签中写本地仓库路径,注意正向分隔符 -->
<localRepository>D:/Java/mvn-repository/.m2/repository</localRepository>
<!-- 配置阿里云镜像,官网下载太慢了 -->
<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>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
-->
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
验证,在cmd窗口输入 mvn help:system
,会使用阿里镜像下载资源的本地仓库中就表示配置成功了!