Maven 是一个基于 Java 的项目管理工具,可以对 Java 项目进行构建、依赖管理,所以使用maven首先需要安装对应的JDK。
Maven 3.3 要求 JDK 1.7 或以上
Maven 3.2 要求 JDK 1.6 或以上
Maven 3.0/3.1 要求 JDK 1.5 或以上
1、下载并解压Maven
下载maven的bin文件并解压在目录中,目录路径避免中文、特殊字。
下载地址:http://maven.apache.org/download.cgi
2、修改配置文件
修改conf目录里面的settings.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--配置maven本地仓库位置-->
<localRepository>D:/Java/Installation Package/apache-maven-3.6.3/repository</localRepository>
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers></servers>
<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> maven-net-cn</id>
<name> Maven China Mirror</name>
<url> http://maven.net.cn/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<!--配置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>
</profiles>
</settings>
3、配置Maven环境变量
添加 MAVEN_HOME系统变量
修改系统变量的Path,添加 %MAVEN_HOME%\bin
4、验证
打开cmd,输入 mvn --version ,输出如下信息代表成功
5、IDEA配置