Mac添加maven环境变量

文章目录

      • 1. 终端
      • 2. 更新环境变量
      • 3. 设置永久生效
      • 4. 测试

1. 终端

vim ~/.bash_profile

i 进入编辑模式

export M2_HOME=/Users/wanfei/myMac/javaRuanJian/maven/apache-maven-3.8.6
export PATH=$PATH:$M2_HOME/bin

2. 更新环境变量

source ~/.bash_profile

每次都需要更新一下

3. 设置永久生效

切换到root账号

sudo su

然后

cd /etc 
vim zshrc

i,后面添加

source ~/.bash_profile

然后esc后输入:wq!

重启生效,或者重新开终端cd/etc下执行source zshrc

4. 测试

wanfei@mofeideMacBook-Pro ~ % mvn -v
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /Users/wanfei/myMac/javaRuanJian/maven/apache-maven-3.8.6
Java version: 11.0.17, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.17.jdk/Contents/Home
Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "13.4.1", arch: "aarch64", family: "mac"

你可能感兴趣的:(macos,maven,java)