Bootstrap

Maven安装及配置

1 Maven安装

  从官网下载Maven安装包:apache-maven-3.9.8-bin.zip,这是一个压缩包,解压到D:\Java目录下。
安装完目录结构如下:
安装目录

2 配置

2.1 PATH路径配置

如下图所示配置PATH环境变量:
MavenPath

2.2 配置仓库

  在D:/Java/apache-maven-3.9.8/目录下创建目录repository作为软件包下载仓库。
打开文件D:/Java/apache-maven-3.9.8/conf/settings.xml,添加本地仓库:

<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  <!-- 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/apache-maven-3.9.8/repository</localRepository>

2.3 配置国内镜像

打开文件D:/Java/apache-maven-3.9.8/conf/settings.xml,添加国内镜像提高下载速度,这里选择阿里云:

  <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>aliyunmaven</id>
    <mirrorOf>*</mirrorOf>
    <name>阿里云公共仓库</name>
    <url>https://maven.aliyun.com/repository/public</url>
  </mirror>
  </mirrors>

3 验证

在命令上运行如下命令:

C:\Users\flysnow>mvn --version
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Maven home: D:\Java\apache-maven-3.9.8
Java version: 11, vendor: Oracle Corporation, runtime: D:\Java\jdk-11
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

如果显示如上信息说明安装成功了。

4 IntelliJ IDEA中配置Maven

如下图所示:
![IDEA Set1](https://i-blog.csdnimg.cn/direct/a44fcc5428c74cf7bfc833be73507fe7.png#pic_center
IDEA Set2

;