Home  >  Article  >  Java  >  Simple and easy to understand CentOS7 installation Maven tutorial

Simple and easy to understand CentOS7 installation Maven tutorial

王林
王林Original
2024-02-21 15:18:03416browse

Simple and easy to understand CentOS7 installation Maven tutorial

Installing Maven on CentOS7 is an essential step when developing Java projects. This tutorial will introduce in detail how to install and configure Maven on CentOS7 systems, and provide specific code examples to help readers quickly complete the installation process.

Step 1: Download Maven

First, visit the Maven official website (https://maven.apache.org/download.cgi) to download the latest version of the Maven compressed package. You can choose to download files in bin.tar.gz or bin.zip format. Suppose we save the downloaded file in the /opt directory.

Step 2: Decompress Maven

Next, open the terminal, enter the /opt directory, and execute the following command to decompress the Maven file:

cd /opt
tar -zxvf apache-maven-3.x.x-bin.tar.gz     # 解压文件,版本号可能不同

Step 3: Configure environment variables

Edit the /etc/profile file and add the following configuration at the end:

export MAVEN_HOME=/opt/apache-maven-3.x.x     # Maven解压目录
export PATH=$PATH:$MAVEN_HOME/bin

Make the configuration effective:

source /etc/profile

Step 4: Verify the installation

Enter the following command to verify whether Maven is successfully installed:

mvn -version

If you see information similar to the following, Maven has been successfully installed:

Apache Maven 3.x.x
Maven home: /opt/apache-maven-3.x.x
Java version: 1.8.0_282, vendor: AdoptOpenJDK

At this point, we have completed the installation of Maven on CentOS7 A step of. Now you can use Maven to build and manage Java projects.

I hope this tutorial can help readers successfully install Maven and develop Java projects smoothly. Happy programming!

The above is the detailed content of Simple and easy to understand CentOS7 installation Maven tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn