折腾:
【已解决】VSCode调试Java弹框提示:Maven executable not found in PATH Please specifiy maven.executable.path in Settings
期间,突然感觉,或许此处提示,就是因为mac中缺少maven
所以要去mac中安装maven
mac install maven
mac maven
maven
Maven – Welcome to Apache Maven
Maven Repository: Search/Browse/Explore
Maven 3.3+ require JDK 1.7 or above to execute – they still allow you to build against 1.3 and other JDK versions by Using Toolchains
➜ 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
Maven – Installing Apache Maven
确保mac中已设置好JAVA_HOME
【已解决】maven环境变量设置成M2_HOME还是M3_HOME还是MAVEN_HOME
所以只需要去设置Maven的bin的路径
/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin
到path中
vi ~/.bashrc export PATH=/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin:$PATH source ~/.bashrc
去确认已安装:
➜ 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"
此处,还有点担心,没有设置
/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3
为maven的home相关的变量呢
发现从maven版本输出信息中有:
Maven home: /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3
意味着:其maven自己就可以从mvn的bin所在路径
Maven home: /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin
推断出上一级目录就是maven的home的目录
-》所以最新版maven不需要设置home相关目录,更不需要设置之前的M2_HOME,就是这个意思了。
后来去回答了帖子:
macos – Maven Install on Mac OS X – Stack Overflow
java – How to ensure maven is installed in mac – Stack Overflow
【总结】
mac中安装maven
(1)用brew
brew install maven
但是不一定是最新版。
(2)手动下载和安装最新版
从官网
下载zip二进制安装包,比如:
放到某个目录:/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3
解压,其中有bin,lib等子目录,bin下面有mvn二进制可执行文件
把对应目录的bin路径,放到PATH中:
编辑启动脚本
vi ~/.bashrc
再.bashrc的最后加上:
export PATH=/Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin:$PATH
然后wq保存退出。
回到终端,想要立刻生效可以:
source ~/.bashrc
确认是否已正确安装:
➜ 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中安装maven