bash - 获取-bash : mvn: command not found

标签 bash maven-2 macos

我尝试在 .profile 文件中设置 Maven PATH,并在终端 (Mac OSX) 中使用导出命令。但是,在运行 mvn 命令时,得到 -bash: mvn: command not found

请帮忙。

最佳答案

你具体设置了什么?您是否像这样设置 PATH(或类似的东西):

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

如果是,您是否注销并重新登录?根据 bash 联机帮助页:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
...
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

如您所见,.profile 中的命令不会针对非登录 shell(登录后打开的 shell 类型)执行。因此,您必须注销/登录或手动获取文件以考虑您的设置。看这个blog post更多细节。

关于bash - 获取-bash : mvn: command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1606174/

相关文章:

maven-2 - 在 Maven 构建期间将内存中的 HSQL 数据库内容导出为 SQL

maven-2 - 使用 JMeter + Maven 和 https 协议(protocol)

python - 如何使用 Windows CMD 将包上传到 PyPI?

macos - 如何强制 CPAN 构建使用 INC 和 LIB 路径默认值 (cpanm+perlbrew)

linux - 如何使用 sed 仅删除文件中第一次出现的行

alias - ~/.bashrc 别名更改目录不起作用

maven-2 - 为什么版本匹配在 Maven 中不起作用?

macos - 如何在 OS X 下的视网膜/非视网膜屏幕上使用相同的方法加载不在资源目录中的图像?

bash - Linux gnu 少 : long lines in buffer broken down when copy+pasting

bash - 使用 awk 的最近邻居