Maven
官网下载地址Maven – Download Apache Maven
注意,不同版本的IEDA需要下载对应版本的Maven
- [0.IDEA 2022 兼容maven 3.8.1及之前的所用版本]
- [1.IDEA 2021 兼容maven 3.8.1及之前的所用版本]
- [2.IDEA 2020 兼容Maven 3.6.3及之前所有版本]
- [3.IDEA 2018 兼容Maven3.6.1及之前所有版本]
注意:全程路径需要使用一个非中文、没有空格的目录。
- 在解压目录中,我们需要着重关注 Maven 的核心配置文件:conf/settings.xml以下的配置都是在这个文件中
指定本地仓库
记住:一定要把 localRepository 标签从注释中拿出来。
<!-- 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>D:\JAVA\maven\maven-repo</localRepository>
配置阿里云提供的镜像仓库
http://maven.aliyun.com/nexus/content/groups/public
<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>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
配置 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>
配置环境变量
MAVEN_HOME:安装路径[D:\Java\maven\apache-maven-3.6.1]
Path:%MAVEN_HOME%\bin
验证是否安装成功
C:\Users\King‘sLanding>mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: D:\JAVA\maven\apache-maven-3.6.1\bin\..
Java version: 1.8.0_131, vendor: Oracle Corporation, runtime: D:\JAVA\jdk1.8.0_131\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
C:\Users\King‘sLanding>
## IEDA中创建Maven
这是尚硅谷的教程地址
Maven:IDEA环境 | 代码重工 (gitee.io)
注意:每次创建 Project 后都需要设置 Maven 家目录位置,否则 IDEA 将使用内置的 Maven 核心程序(不稳定)并使用默认的本地仓库位置。这样一来,我们在命令行操作过程中已下载好的 jar 包就白下载了,默认的本地仓库通常在 C 盘,还影响系统运行。
如何不每次启动都要设置一次
选择Maven,修改为自己的配置