MVN命令OSX Mavrerick未找到 [英] mvn command not found in OSX Mavrerick

查看:132
本文介绍了MVN命令OSX Mavrerick未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标记这是重复之前,我通过这些帖子去了,但没有任何帮助。
<一href=\"http://stackoverflow.com/questions/13697874/mvn-is-not-recognized-as-an-internal-or-external-command?rq=1\">'mvn'不被识别为一个内部或外部命令, ​​获得-bash:MVN:找不到命令无法从命令行访问MVN命令?

有些是特定于Windows,并没有帮助。在Mac OS X他们夫妇给的建议,我试过,但没有帮助。

我试过(这正是的Maven 建议):


  

解压发行包,即Apache的行家-3.1.1-bin.tar.gz
  的目录,你希望安装Maven 3.1.1。这些指令
  假设你选择在/ usr /本地/ Apache Maven的。子目录
  Apache的行家-3.1.1将从档案创建。在命令
  终端,加上M2_HOME环境变量,例如出口
  M2_HOME =的/ usr /本地/ Apache Maven的/ Apache的行家-3.1.1。新增M2
  环境变量,例如出口M2 = $ M2_HOME / bin中。可选:添加
  MAVEN_OPTS环境变量指定JVM属性,例如出口
  MAVEN_OPTS = - Xms256m -Xmx512m。此环境变量可用于
  提供额外的选项来Maven的。添加M2环境变量到你
  路径,例如出口PATH = $ M2:$ PATH。确保JAVA_HOME设置为
  你的JDK,例如位置出口JAVA_HOME =的/ usr / JAVA / jdk1.5.0_02
  和$ JAVA_HOME / bin在PATH环境变量。运行mvn
  --version以验证它是否正确安装。


我看到的端子,我用于安装,它工作正常。我没有这个问题。但是当我尝试了新的终端,我得到命令没有找到

我还添加了出口PATH = $ M2 我的的.bashrc ,我做了,然后重新启动终端,它仍然没有帮助。

可以有人建议如何使其在终端的所有会话中可用?

感谢


解决方案

试试下面的一些,如果这些可以帮助:

由于您的安装工程已安装在终端上,所有的出口你没有,在当前bash的工作及其子进程。但不催生新的终端

如果会话关闭ENV 变量都将丢失;使用的.bash_profile ,你可以把它在所有会话中使用,因为当一个庆典会话启动,它的运行其的.bashrc和.bash_profile中

现在请按照下列步骤,看看是否有帮助:


  1. 键入 ENV | grep的M2_HOME 正在工作的终端上。这应该给像

    M2_HOME =的/ usr /本地/ Apache Maven的/ Apache的行家-3.1.1


  2. 键入 ENV | grep的JAVA_HOME 应该给这样的:

    JAVA_HOME = /图书馆/的Java / JavaVirtualMachines / jdk1.7.0_40.jdk /内容/首页


现在您对PATH M2_HOME JAVA_HOME

如果你只是做 LS /usr/local/apache-maven/apache-maven-3.1.1/bin ,你将看到 MVN 二进制那里。
所有你现在要做的是指使用PATH这个位置每次。因为庆典中提到的所有的目录路径PATH ,它会找到 MVN


  1. 现在打开的.bash_profile ,如果你没有一位刚刚创建一个

    六,在〜/ .bash_profile


添加以下内容:

 #设置JAVA_HOME
JAVA_HOME = /图书馆/的Java / JavaVirtualMachines / jdk1.7.0_40.jdk /内容/首页
出口JAVA_HOME
M2_HOME =的/ usr /本地/ Apache Maven的/ Apache的行家-3.1.1
出口M2_HOMEPATH = $ PATH:$ JAVA_HOME /斌:$ M2_HOME / bin中
导出路径


  1. 保存文件,并键入源在〜/ .bash_profile 。此步骤执行中的的.bash_profile 文件中的命令,你是好走了。


  2. 打开一个新的终端,然后键入 MVN ,应该工作。


Before marking this as duplicate, I went through these posts, but nothing helped. 'mvn' is not recognized as an internal or external command, Getting -bash: mvn: command not found, Can't access mvn command from command line?

Some are specific to windows and did not help. A couple of them on Mac OS X gave suggestions, that I tried but did not help.

What I tried (this is exactly what Maven suggests):

Extract the distribution archive, i.e. apache-maven-3.1.1-bin.tar.gz to the directory you wish to install Maven 3.1.1. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.1.1 will be created from the archive. In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1. Add the M2 environment variable, e.g. export M2=$M2_HOME/bin. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven. Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.5.0_02 and that $JAVA_HOME/bin is in your PATH environment variable. Run mvn --version to verify that it is correctly installed.

I see that on the terminal that I used for installation, it works fine. I do not have this issue. but when I tried on a new terminal, I get command not found.

I also added export PATH=$M2 to my .bashrc, I did source and then restarted the terminal, still it did not help.

can someone suggest how to make it available in all sessions of terminal?

Thanks

解决方案

Try following these if these might help:

Since your installation works on the terminal you installed, all the exports you did, work on the current bash and its child process. but is not spawned to new terminals.

env variables are lost if the session is closed; using .bash_profile, you can make it available in all sessions, since when a bash session starts, it 'runs' its .bashrc and .bash_profile

Now follow these steps and see if it helps:

  1. type env | grep M2_HOME on the terminal that is working. This should give something like

    M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1

  2. typing env | grep JAVA_HOME should give like this:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home

Now you have the PATH for M2_HOME and JAVA_HOME.

If you just do ls /usr/local/apache-maven/apache-maven-3.1.1/bin, you will see mvn binary there. All you have to do now is to point to this location everytime using PATH. since bash searches in all the directory path mentioned in PATH, it will find mvn.

  1. now open .bash_profile, if you dont have one just create one

    vi ~/.bash_profile

Add the following:

#set JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
export JAVA_HOME


M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1
export M2_HOME

PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH

  1. save the file and type source ~/.bash_profile. This steps executes the commands in the .bash_profile file and you are good to go now.

  2. open a new terminal and type mvn that should work.

这篇关于MVN命令OSX Mavrerick未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆