Mac下安装和配置Maven

时间:2021-08-12 04:14:30

1、下载Maven

  官网:http://maven.apache.org/download.cgi

  下载版本:apache-maven-3.5.3-bin.tar.gz

2、配置环境变量

  打开terminel输入以下命令:

//打开.bash_profile文件
1、vim ~/.bash_profile  
//添加设置环境变量的命令
2、export M2_HOME=/Users/yuanweipeng/Documents/maven/apache-maven-3.5.0
  export PATH=$PATH:$M2_HOME/bin

  如果不能保存 提示没有权限可以强制保存退出::wq!

  添加之后保存并推出,执行以下命令使配置生效:

3、source ~/.bash_profile

3、查看配置是否生效

  输入 mvn -v,输出如下

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: /Users/zhanyunjiu/Documents/apache-maven-3.5.3
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.2", arch: "x86_64", family: "mac"
zhanyunjiudeMacBook-Pro:~ zhan$

  安装成功