mac(arm架构)安装maven

Apache Maven 是一个软件项目包管理的综合工具,可以很方便的帮助我们构建项目,记录一下mac安装过程。因为maven依赖JDK,所以安装前确定是否已经安装JDK,如果没有安装参考mac(arm架构)安装jdk

安装步骤

下载地址

如果要下载最新的maven,可以直接访问maven官网下载地址,如果下载历史版本点击历史版本找到对应的版本下载即可,我这里下载的是apache-maven-3.8.3-bin.tar.gz版本。
在这里插入图片描述
下载完我把软件都放在了/User/lth下,这个可以自定义,跟windows里的磁盘一样。

解压

运行解压命令

tar -zxvf apache-maven-3.8.3-bin.tar.gz

配置环境变量

编辑~/.zshrc文件,添加maven路径

export MAVEN_HOME=/Users/lth/maven/apache-maven-3.8.3
export PATH=$MAVEN_HOME/bin:$PATH

刷新配置

运行刷新命令

source ~/.zshrc

测试安装成功

mvn -v

如果成功会输出maven信息
在这里插入图片描述

配置maven本地库

按照上面步骤安装成功之后,配置自定义maven本地库位置,位置在maven的的conf文件夹下的settings.xml

打开setting文件

vim settings.xml

贴上我的配置内容

<?xml version="1.0" encoding="UTF-8"?>

<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>/Users/lth/maven/repo</localRepository>

  <mirrors>
    <mirror>
      <id>central</id>
      <mirrorOf>central</mirrorOf>
      <url>https://repo1.maven.org/maven2</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>gf</id>
      <repositories>
        <repository>
          <id>maven-default</id>
          <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-8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>8</jdk>
      </activation>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>gf</activeProfile>
  </activeProfiles>
</settings>

修改为自己的库配置即可,也就是以后jar包位置

<localRepository>自己的地址</localRepository>

国内访问maven官方仓库有点慢的可以将配置改为阿里等大厂的maven地址。

<!-- 如:阿里云中央仓库镜-->
<mirror>        
  <id>alimaven</id>
  <name>aliyun-maven</name>
  <mirrorOf>central</mirrorOf>
  <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值