Maven is a Java project management tool used to manage project construction, dependencies, document generation, etc. This article will teach you step by step how to install and configure Maven, help you get rid of confusion during the installation and configuration process, and let you easily get started using Maven for project management.
First, open Maven’s official website (https://maven.apache.org) and find the download page on the homepage of the website. Select the appropriate Maven version to download based on your operating system. Typically, you can choose to download a zip file.
After the download is complete, unzip the zip file to the directory you want to install. This directory will become the Maven installation directory, let's call it Maven_Home
for now.
MAVEN_HOME
in "System Variables", variable The value is the Maven installation directory (for example, C:Program Files pache-maven-3.6.3
). Path
variable in "System Variables", double-click to open it, add ;%MAVEN_HOME% in
at the end of the variable value, and then click OK to save. Open the command prompt (CMD) and enter the following command to verify whether Maven is successfully installed:
mvn -version
If the Maven version appears information, the installation is successful.
Maven’s settings.xml
file is located in the conf
folder under the Maven installation directory. According to your project needs, you can configure proxy, mirror and other information in the settings.xml
file to speed up project construction.
Now that you have successfully installed and configured Maven, let us try to create a Maven project. Open a command prompt, enter a directory where you want to create a Maven project, and enter the following command:
mvn archetype:generate -DgroupId=com.example -DartifactId=my-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The above command will create a basic Maven project, where groupId
represents the organization of the project ID, artifactId
represents the project ID. Modify these parameters according to your needs.
Enter the project directory you just created and enter the following command to build the project:
mvn package
Maven will automatically download the dependencies required for the project and Start building the project. After the build is successful, you will find the generated jar package in the target
directory.
Through the above steps, you have completed the installation and configuration of Maven, successfully created a Maven project, and successfully built the project. I hope this article can help you and enable you to better use Maven for Java project management.
The above is the detailed content of Teach you step by step to complete the installation and configuration of Maven, no longer confused. For more information, please follow other related articles on the PHP Chinese website!