Maven包配置教程

Maven包配置教程

一、找到自己需要下载的maven版本

maven建议下载和idea自带的maven版本一致的

如何找idea自带的maven版本?看下图,

Maven home directory(Maven主目录)选择默认的Bundled(Maven 3),此时下方就会显示版本为Version: 3.3.9

二、下载maven

maven下载地址

  1. 如下图,选择maven-3点击进入

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xWMpaiNX-1674972852045)(http://images-bed.wangqinzw.top/202301291324425.png)]

  1. 找到对应的版本,点击binaries进入,source为源码,用不到

  1. windows选择apache-maven-3.3.9-bin.zip 点击下载即可

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vr3I89mp-1674972852047)(C:/Users/Administrator/AppData/Roaming/Typora/typora-user-images/1674970014586.png)]

  1. 下载下来解压后的文件如下图

三、配置maven,并且把maven仓库移动

  1. maven仓库一般默认在c盘,重装系统,就需要重新下载,比较麻烦。

​ 可以直接把maven仓库,配置在d盘

​ 在d盘新建D:\maven\repo,如图

  1. 修改settings.xml文件

    文件路径:D:\maven\apache-maven-3.3.9\conf

    第一步:将maven仓库,改为新建的maven仓库

    大概在49行到52行原来是这样的,其中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
       | The path to the local repository maven will use to store artifacts.
       |
       | Default: ${user.home}/.m2/repository-->
      <localRepository>D:\maven\repo</localRepository>
    

    第二步:将资源镜像改外阿里云镜像的,节省下载时间

    大概在135-159行,其中mirrors镜像

    <!-- 原来 -->
    <!-- mirrors
       | This is a list of mirrors to be used in downloading artifacts from remote repositories.
       |
       | It works like this: a POM may declare a repository to use in resolving certain artifacts.
       | However, this repository may have problems with heavy traffic at times, so people have mirrored
       | it to several places.
       |
       | That repository definition will have a unique id, so we can create a mirror reference for that
       | repository, to be used as an alternate download site. The mirror site will be the preferred
       | server for that repository.
       |-->
      <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>
         -->
      </mirrors>
    
    <!-- 修改后 -->
    <!-- mirrors
       | This is a list of mirrors to be used in downloading artifacts from remote repositories.
       |
       | It works like this: a POM may declare a repository to use in resolving certain artifacts.
       | However, this repository may have problems with heavy traffic at times, so people have mirrored
       | it to several places.
       |
       | That repository definition will have a unique id, so we can create a mirror reference for that
       | repository, to be used as an alternate download site. The mirror site will be the preferred
       | server for that repository.
       |-->
      <mirrors>
        <mirror>
          <id>alimaven</id>
          <mirrorOf>central</mirrorOf>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>
        <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
        </mirror>
        <!-- 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>
         -->
      </mirrors>
    

    第三步:将settings.xml文件复制一份到maven仓库文件夹下

    ​ 路径:D:\maven\repo\settings.xml

四、配置环境变量

这里不过多说明,不会配置环境变量自行百度。

五、验证是否配置成功

到此步即完成所有配置!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

张先生002

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

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

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

打赏作者

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

抵扣说明:

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

余额充值