mvn -version 正在显示 -bash: /usr/local/bin/mvn: 没有那个文件或目录。知道如何解决这个问题吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24666042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 10:50:09  来源:igfitidea点击:

mvn -version is displaying -bash: /usr/local/bin/mvn: No such file or directory. Any idea how I can fix this?

javabashmavenosx-mavericks

提问by seeker

I was trying to upgrade from Maven 2 to Maven 3.1 on os x mavericks. I tried using brew install maven, thinking it would upgrade maven to the latest version. However that didnt help. It showed the same No such file or directorymessage. Following this,I uninstalled the maven(installed through brew) by doing brew rm maven.

我试图在 os x Mavericks 上从 Maven 2 升级到 Maven 3.1。我尝试使用brew install maven,认为它会将 maven 升级到最新版本。然而这并没有帮助。它显示了相同的No such file or directory消息。在此之后,我通过执行brew rm maven.

However, now I cannot seem to get back either version of maven when I try mvn -v, I get thhe output -bash: /usr/local/bin/mvn: No such file or directory

但是,现在我尝试时似乎无法取回任一版本的 maven mvn -v,我得到了输出 -bash: /usr/local/bin/mvn: No such file or directory

The following is the content of my bash_profile

以下是我的内容 bash_profile

export M2_HOME=/usr/local/apache-maven-2.2.1/
export JBOSS_HOME=/Applications/whp-jboss-cluster-5
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/

export TOMCAT_HOME=/Library/Tomcat/
export PATH=$PATH:$M2_HOME/bin:$JBOSS_HOME/bin:$JAVA_HOME:$TOMCAT_HOME

Any idea on how I can fix this and get to maven 3 would be appreciated.

关于如何解决此问题并使用 maven 3 的任何想法将不胜感激。

回答by Josh Berry

It looks like you have all of the necessary ingredients. You simply need to source your profile so that those changes take effect. (You can do this with . ~/.bash_profile.)

看起来您拥有所有必要的成分。您只需要获取您的个人资料,以便这些更改生效。(你可以用 来做到这一点. ~/.bash_profile。)

It is possible that your shell cached a previous version of mvn. This can happen if you add an item to your path after something of the same name has been used before. In that case, as Etan pointed out in the comments, you can just hash -r, to clear things up. (This doesn't seem to be what you were seeing, but is worth trying in the future if you add maven 3 and mvn -versionkeeps showing version 2.)

您的 shell 可能缓存了以前版本的mvn. 如果您在之前使用过同名的东西之后将一个项目添加到您的路径中,就会发生这种情况。在这种情况下,正如 Etan 在评论中指出的那样,您可以hash -r, 来解决问题。(这似乎不是您所看到的,但是如果您添加 maven 3 并mvn -version继续显示版本 2 ,那么将来值得尝试。)

To get Maven 3 running, it should just be these steps. Just, with your path having the maven 3 directory instead of the maven 2 one.

要让 Maven 3 运行,它应该只是这些步骤。只是,您的路径具有 maven 3 目录而不是 maven 2 目录。