IDEA项目的maven包位置在:/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3
,所以运行:
步骤一:添加环境变量
我的环境变量在zshrc文件下,大家也可以修改 /.bash_profile,/.profile等文件
open -e ~/.zshrc
然后添加:
export MAVEN_HOME=/Applications/IntelliJ\ IDEA.app/Contents/plugins/maven/lib/maven3export PATH=$MAVEN_HOME/bin:$PATH
保存后退出,然后使之生效:
source ~/.zshrc
然后测试一下,能提示出这个命令即可:
mvn -v
步骤二:修改权限
chmod +x /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/bin/mvn
然后测试:
mvn -v
可以看到输出:
Maven home: /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3Java version: 15.0.1, vendor: Oracle Corporation, runtime: /Users/xq/Library/Java/JavaVirtualMachines/openjdk-15.0.1/Contents/HomeDefault locale: en_US, platform encoding: UTF-8OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"