简体   繁体   English

找不到 Mvn 命令?

[英]Mvn Command not found?

I was working on my maven installation and was messing with a few variables to fix an error and now seemed to have lost it altogether.我正在我的 maven 安装工作,并弄乱了一些变量来修复错误,现在似乎完全丢失了它。 My PATH variable is set up correctly along with my JAVA_HOME, but I still get我的 PATH 变量与我的 JAVA_HOME 一起正确设置,但我仍然得到

-bash: mvn: command not found

I tried deleting the maven files and re-downloading them and opening a new terminal, but no luck.我尝试删除 Maven 文件并重新下载它们并打开一个新终端,但没有运气。 Are there any other trouble shooting techniques I can run through to hopefully figure out my problem.是否有任何其他故障排除技术我可以运行以希望找出我的问题。 I am running on a Mac.我在 Mac 上运行。

I had a similar issue, having, mvn not found after installing with sdkman.我遇到了类似的问题,使用 sdkman 安装后mvn not found If you installed with sdkman just like me, you may want to execute: sdk use maven version eg:如果你像我一样安装了 sdkman,你可能需要执行:sdk use maven version eg:

$ sdk use maven 3.6.3


# Install skman.
$ curl -s "https://get.sdkman.io" | bash
$ source ~/.sdkman/bin/sdkman-init.sh

# Check available maven versions:
$ sdk list java
$ sdk list maven

# install desired candidate and version
$ sdk install java 13.0.1-open
$ sdk install gradle
$ sdk install maven
$ sdk install springboot


# Verify Installation by checking versions:
$ java -version
$ gradle -v
$ mvn --version
$ spring --version

If it is linux machine and you install directly using yum, then you could find the maven in /usr/local如果是linux机器,直接用yum安装,可以在/usr/local下找到maven

So you can set the MAVEN_HOME in ~/.bashrc and do source ~/.bashrc to make it permanent.因此,您可以在 ~/.bashrc 中设置 MAVEN_HOME 并执行 source ~/.bashrc 以使其永久化。

Do check by $echo MAVEN_HOME and $echo JAVA_HOME通过 $echo MAVEN_HOME 和 $echo JAVA_HOME 检查

If you get exact path of both, then it will be fine.如果你得到两者的确切路径,那就没问题了。

Check that, don't forguet to restart the machine检查一下,不要忘记重新启动机器

检查一下,不要忘记重新启动机器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM