Maven安装和下载以及镜像配置(亲测,绝对好用!)

其他资源

1.MavenRepository:Maven Repository: Search/Browse/Explore (mvnrepository.com)

通过他,我们能查找Maven中央仓库具有的依赖坐标,从而导入使用它。

Maven和jdk对应的版本

作者,我这里 jdk14 使用不了 maven3.8 以上的版本

1.下载和安装

1.点击进入MavenMaven – Welcome to Apache Maven

 

 2.如下图,windows要下载的zip包。

 3.之后点击下载解压到你安装的目录,我是放到了D盘。

D:\tools\apache-maven-3.6.1

 2.配置环境变量

其实用户变量和全局变量没啥区别,就是权限区别。

参考我下面那张图:

M2_HOME 你的Maven安装目录(MAVEN_HOME也可以)

 

 

之后,打开控制台 输入 mvn -v

 安装成功了!

3.Maven配置多仓库

maven仓库在国外,我们的依赖下载是非常慢的,所以要用到国内镜像库,但是有些依赖镜像库是没有的,又必须从中央仓库下载。

我建议

这里我配置的是阿里云的镜像库

建议本地仓库安装在你的Maven的安装包里,这样好找。

 1.配置本地仓库

就是上图仓库的路径

<!-- 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:/tools/apache-maven-3.6.1/repository</localRepository>

2. 配置镜像库

 |-->
  <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>aliyun</id>
    	<mirrorOf>central</mirrorOf>
    	<name>aliyun</name>
    	<url>https://maven.aliyun.com/repository/public</url>
    </mirror>


  </mirrors>

3.配置中央仓库

这一堆是在<profiles></profiles>里面。

  <profile>
        <id>gf</id>
        <repositories>
            <repository>
                <id>maven-default</id>
                   <!-- 注意这个http要带s,不然访问不到,我看很多都没带,所以访问不了。  -->
                <url>https://repo1.maven.org/maven2/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
    <profile>
      <id>jdk-14</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>14</jdk>
      </activation>
      <properties>
        <maven.compiler.source>14</maven.compiler.source>
        <maven.compiler.target>14</maven.compiler.target>
        <maven.compiler.compilerVersion>14</maven.compiler.compilerVersion>
      </properties>
    </profile>

4.最后一个看下图。

<activeProfiles>
    <activeProfile>aliyun</activeProfile>
    <activeProfile>gf</activeProfile>
  </activeProfiles>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

本郡主是喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值