[英]Install latest maven package in Ubuntu via apt package manager or other ways
I am trying to install maven in linux machine using the following command:我正在尝试使用以下命令在 linux 机器中安装 maven:
sudo apt install maven
But this command installs the maven version 3.6.0, whereas the latest version for maven in the apache maven web-site is 3.8.1. But this command installs the maven version 3.6.0, whereas the latest version for maven in the apache maven web-site is 3.8.1. Any suggestions on how to install maven 3.8.1 via apt install command or any else ways?
关于如何通过 apt install 命令或任何其他方式安装 maven 3.8.1 的任何建议?
This is a small guide to install maven on ubuntu 20.04 LTS.这是在 ubuntu 20.04 LTS 上安装 maven 的小指南。 Jul 28, 2021
2021 年 7 月 28 日
Download maven from https://maven.apache.org/download.cgi click the link apache-maven-3.8.1-bin.tar.gz.从https://maven.apache.org/download.cgi下载 maven 点击链接 apache-maven-3.8.1-bin.tar。
Extract the files in your downloads folder.提取下载文件夹中的文件。
cd Downloads
sudo tar xzvf apache-maven-3.8.1-bin.tar.gz -C/opt/
In a terminal window enter the following.在终端 window 中输入以下内容。
nano.profile
Edit the file and add the following text at the bottom of the page.编辑文件并在页面底部添加以下文本。
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JAVA_HOME
MAVEN_HOME=/opt/apache-maven-3.8.1
export MAVEN_HOME
PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
export PATH
Now press ctrl + O to save the file, and ctrl + X to close the file.现在按 ctrl + O 保存文件,按 ctrl + X 关闭文件。
Back in the terminal run the script with.回到终端运行脚本。
. .profile
Check the version of java and maven with the commands.使用命令检查 java 和 maven 的版本。
`java --version`
`mvn --version`
Now you should see the proper version of Maven installed.现在您应该看到安装了正确版本的 Maven。
If you open a new terminal window and the installation seems ineffective: LOGOUT AND LOGIN!!!**如果您打开一个新终端 window 并且安装似乎无效:LOGOUT AND LOGIN!!!**
Build it from the source.从源头构建它。 https://maven.apache.org/download.cgi
https://maven.apache.org/download.cgi
Installing Maven
安装 Maven
Unix-based operating systems (Linux, Solaris and Mac OS X)
tar zxvf apache-maven-3.x.y.tar.gz
Windows
unzip apache-maven-3.x.y.zip
A directory called "apache-maven-3.xy" will be created.将创建一个名为“apache-maven-3.xy”的目录。
Add the bin directory to your PATH, eg:将 bin 目录添加到您的 PATH,例如:
Unix-based operating systems (Linux, Solaris and Mac OS X)
export PATH=/usr/local/apache-maven-3.x.y/bin:$PATH
Windows
set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH%
Make sure JAVA_HOME is set to the location of your JDK确保将 JAVA_HOME 设置为 JDK 的位置
Run "mvn --version" to verify that it is correctly installed.运行“mvn --version”以验证它是否已正确安装。
For complete documentation, see https://maven.apache.org/download.html#Installation有关完整文档,请参阅https://maven.apache.org/download.html#Installation
JAVA_HOME=/usr/ib/jvm/java-11-openjdk-amd64
should be JAVA_HOME=/usr/ lib /jvm/java-11-openjdk-amd64
which is the default Java 11 (OpenJDK) directory. JAVA_HOME=/usr/ib/jvm/java-11-openjdk-amd64
应该是JAVA_HOME=/usr/ lib /jvm/java-11-openjdk-amd64
这是默认的 Java 11 (OpenJDK) 目录。
Following command helped me.以下命令帮助了我。
Remove current version:删除当前版本:
sudo apt-get purge maven
Download the latest version:下载最新版本:
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
Installation:安装:
sudo cp -r apache-maven-3.8.6 /opt
export PATH=/opt/apache-maven-3.8.6/bin:$PATH
Note : Make sure Java should install before following the above steps.注意:在执行上述步骤之前,请确保 Java 应该安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.