我正在尝试按照这些说明通过终端安装maven。
到目前为止我得到了这个:
export M2_HOME=/user/apple/apache-maven-3.0.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/java/jdk1.6.0_22
你去哪儿找这个?
我正在尝试按照这些说明通过终端安装maven。
到目前为止我得到了这个:
export M2_HOME=/user/apple/apache-maven-3.0.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/usr/java/jdk1.6.0_22
你去哪儿找这个?
当前回答
在马华力号上,在终点站跑 xcode-select——安装 安装命令行工具。
其他回答
macOS Sierra以上
Brew安装专家
在马华力号上,在终点站跑 xcode-select——安装 安装命令行工具。
brew install maven31 (if you have homebrew)
只是一个简短的补充;如果您想在MacOS上使用Homebrew 1.5.2安装特定版本,可以通过以下方式安装:
酿造更新 酿造搜索专家
这将为您提供homebrew中可用的maven版本
Brew install maven@3.3
[如果您想安装maven 3.3。]
两个方法
(use homebrew) Auto install: Command: brew install maven Pros and cons Pros: easy Cons: (probably) not latest version Manually install (for latest version): Pros and cons Pros: use your expected any (or latest) version Cons: need self to do it Steps download latest binary (apache-maven-3.6.3-bin.zip) version from Maven offical download uncompress it (apache-maven-3.6.3-bin.zip) and added maven path into environment variable PATH normally is edit and add: export PATH=/path_to_your_maven/apache-maven-3.6.3/bin:$PATH into your startup script( ~/.bashrc or ~/.zshrc etc.)
额外的注意
如何立即生效并检查安装是否正确?
A:
source ~/.bashrc
echo $PATH
which mvn
mvn --version
这里的输出:
➜ bin pwd
/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin
➜ bin ll
total 64
-rw-r--r--@ 1 crifan staff 228B 11 7 12:32 m2.conf
-rwxr-xr-x@ 1 crifan staff 5.6K 11 7 12:32 mvn
-rw-r--r--@ 1 crifan staff 6.2K 11 7 12:32 mvn.cmd
-rwxr-xr-x@ 1 crifan staff 1.5K 11 7 12:32 mvnDebug
-rw-r--r--@ 1 crifan staff 1.6K 11 7 12:32 mvnDebug.cmd
-rwxr-xr-x@ 1 crifan staff 1.5K 11 7 12:32 mvnyjp
➜ bin vi ~/.bashrc
➜ bin source ~/.bashrc
➜ ~ echo $PATH
/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin:xxx
➜ bin which mvn
/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin/mvn
➜ bin mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3
Java version: 1.8.0_112, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
详情请参考我的(中文)帖子:【已解决】Mac中安装Gradle