CentOS7, as a widely used Linux operating system, provides developers with a stable and reliable platform. When developing Java projects, Maven is a very important build tool. It can help developers automatically build projects, manage dependencies, etc. This article will introduce in detail how to install Maven from scratch on CentOS7 and provide specific code examples.
Before installing Maven, you first need to ensure that Java is installed on the system. On CentOS7, you can use the following command to install Java (assuming you are using OpenJDK):
sudo yum install java-1.8.0-openjdk
After the installation is complete, you can use the following command to verify whether Java is successfully installed:
java -version
If Java is successfully displayed version information, the installation is successful.
Next, you need to download the Maven compressed package. You can download Maven through the official website, or use the wget command to download. Assume that we downloaded Apache Maven 3.6.3 version:
wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
After the download is complete, you can use the following command to decompress Maven:
tar -zxvf apache-maven-3.6.3-bin.tar.gz
Next, you need to configure Maven's environment variables so that the system can recognize and use Maven. Edit the /etc/profile
file and add the following content:
export MAVEN_HOME=/path/to/apache-maven-3.6.3 export PATH=$PATH:$MAVEN_HOME/bin
After saving the file, execute the following command to make the environment variables take effect:
source /etc/profile
Finally, use the following command to verify whether Maven is successfully installed:
mvn -version
If the Maven version information is successfully displayed, the installation is successful.
At this point, we have completed the process of installing Maven from scratch on CentOS7. Through the above steps, you can smoothly integrate Maven into your development environment and exert its powerful functions in Java project development.
I hope this article can be helpful to you, and I wish you success in completing the installation and configuration of Maven!
The above is the detailed content of CentOS7 Maven installation tutorial step by step. For more information, please follow other related articles on the PHP Chinese website!