下载Maven
环境变量
*
MAVEN_HOME:maven路径
*
Path:%MAVEN_HOME%\bin
M2_HOME:%MAVEN_HOME%\conf\setting.xml
【你的setting.xm
l位置】
测试
打开Windows powershell输入mvn -v
出现以下内容即为成功;
Microsoft Windows [版本 10.0.18363.836]
(c) 2019 Microsoft Corporation。保留所有权利。
C:\Users\HY>mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: D:\Install\Packges\Apache\apache-maven-3.6.3\bin\..
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: D:\Install\JDK\jdk-8\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
maven配置
找到maven路径下conf/settings.xml
文件,在文件在文件中添加相应代码;
- 设置本地仓库
<localRepository>本地仓库的路径</localRepository>
- 修改maven默认的JDK版本
<profile>
<id>JDK-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
- 添加阿里镜像源
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
注意:在pom.xml
中也可以通过如下代码添加阿里云镜像
<repositories>
<repository>
<id>spring</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>