简体   繁体   English

未找到 Maven 3.0.4 安装到 Ubuntu mvn

[英]Maven 3.0.4 installation to Ubuntu mvn not found

I tried to install Maven to Ubuntu but something goes wrong.我尝试将 Maven 安装到 Ubuntu,但出了点问题。

I downloaded Maven and untarred it to folder /usr/local/apache-maven/apache-maven-3.0.4.我下载了 Maven 并将其解压到文件夹/usr/local/apache-maven/apache-maven-3.0.4. Then I added these rows to /etc/environment.然后我将这些行添加到 /etc/environment。

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

export M2=$M2_HOME/bin出口 M2=$M2_HOME/bin

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$JAVA_HOME:$JRE_HOME:$M2:$PATH" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$JAVA_HOME:$JRE_HOME:$M2:$PATH"

But when I try to verify my installation by mvn --version I get this message但是当我尝试通过mvn --version验证我的安装时,我收到此消息

'The program 'mvn' can be found in the following packages: * maven * maven2 Try: sudo apt-get install ' '程序'mvn'可以在以下软件包中找到:* maven * maven2 Try: sudo apt-get install '

SOLVED.解决了。 Sorry that if forget to reply to this.对不起,如果忘记回复这个。 I added export rows to ~/.bashrc and after that it started to work.我将导出行添加到 ~/.bashrc 之后它开始工作。

Had the same issue, this is how i solved it.有同样的问题,这就是我解决它的方法。

1- Install Maven2 from Synaptic rather than downloading it from the website. 1- 从 Synaptic 安装 Maven2,而不是从网站下载。

2- gedit ~/.bashrc and check if you have M2_HOME and M2 env variables defined if so DELETE them, delete them from PATH too, if there is a reference to them. 2- gedit ~/.bashrc并检查您是否定义了 M2_HOME 和 M2 env 变量,如果有,请删除它们,如果有对它们的引用,也将它们从 PATH 中删除。

3- Reload bash and try mvn --version again. 3- 重新加载 bash 并再次尝试mvn --version

please check if mvn in $M2 is executable.请检查 $M2 中的mvn是否可执行。 if not you need to make it executable by running如果不是,您需要通过运行使其可执行

chmod +x mvn

Since Ubuntu 16.04.3 LTS release, Maven can be installed from the official repository by running following commands:从 Ubuntu 16.04.3 LTS 版本开始,可以通过运行以下命令从官方存储库安装 Maven:

  • sudo apt update sudo apt 更新
  • sudo apt install maven sudo apt 安装 maven

Each time you hit sudo apt update it will update to the latest version.每次您点击sudo apt update它都会更新到最新版本。

Update: After installation is complete, run in the terminal mvn -v to see if package was installed.更新:安装完成后,在终端运行mvn -v查看是否安装了包。

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

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