Table of Contents
1. Maven installation
Home Java javaTutorial In-depth explanation of Maven setup and installation to help you quickly start project construction

In-depth explanation of Maven setup and installation to help you quickly start project construction

Feb 25, 2024 am 11:00 AM
Install maven Configuration Mirror source local warehouse

In-depth explanation of Maven setup and installation to help you quickly start project construction

Maven is a Java project management tool that can help developers build, deploy and manage projects more easily. This article will explain the installation and configuration of Maven in detail to help readers quickly get started and use Maven to build projects.

1. Maven installation

  1. First of all, you need to ensure that the Java development environment (JDK) has been installed on your computer;
  2. Go to the Maven official website (https: //maven.apache.org/download.cgi) Download the latest version of the Maven compressed package;
  3. Extract the downloaded compressed package to the directory of your choice, for example C: pache-maven-3.6 .3;
  4. Configure system environment variables:

    • Create a new system variable named MAVEN_HOME, the value is the Maven installation path (For example C: pache-maven-3.6.3);
    • Edit the system’s Path variable and add %MAVEN_HOME% in# at the end ##;
    • To verify whether the Maven installation is successful, enter
    • mvn -version in the command line. If the Maven version information is displayed, the installation is successful.
2. Maven configuration

    Open the Maven configuration file
  1. settings.xml, located in the Maven installation directory conf folder;
  2. Configure the local warehouse path:

    <localRepository>D:maven-repo</localRepository>
    Copy after login

  3. Configure the mirror source (can speed up downloading):

    <mirrors>
      <mirror>
        <id>nexus</id>
        <mirrorOf>central</mirrorOf>
        <url>http://your.nexus.repo/content/groups/public</url>
      </mirror>
    </mirrors>
    Copy after login

  4. Configure proxy server (if necessary):

    <proxies>
      <proxy>
        <id>example-proxy</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>proxy.example.com</host>
        <port>8080</port>
        <username>proxyuser</username>
        <password>somepassword</password>
        <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
      </proxy>
    </proxies>
    Copy after login

3. Maven usage example

  1. Create A simple Maven project:

    Enter the following command on the command line:

    mvn archetype:generate -DgroupId=com.example -DartifactId=my-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
    Copy after login

  2. Build the project:

    Enter the directory where the project is located and enter the following command to build the project:

    mvn clean install
    Copy after login

  3. Add dependencies:

    Add the required dependencies to the
    pom.xml file of the project, for example:

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>5.2.8.RELEASE</version>
    </dependency>
    Copy after login

  4. Run the project:

    mvn exec:java -Dexec.mainClass="com.example.MyApp"
    Copy after login

4. Summary

Through the above steps, we can easily install, configure and use Maven to build Java projects. Maven's powerful functions and rich plug-in ecosystem can greatly improve the efficiency and quality of project development. I hope this article can help readers better understand and utilize Maven and speed up the project development process.

The above is the detailed content of In-depth explanation of Maven setup and installation to help you quickly start project construction. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

How to install Podman on Ubuntu 24.04 How to install Podman on Ubuntu 24.04 Mar 22, 2024 am 11:26 AM

If you have used Docker, you must understand daemons, containers, and their functions. A daemon is a service that runs in the background when a container is already in use in any system. Podman is a free management tool for managing and creating containers without relying on any daemon such as Docker. Therefore, it has advantages in managing containers without the need for long-term backend services. Additionally, Podman does not require root-level permissions to be used. This guide discusses in detail how to install Podman on Ubuntu24. To update the system, we first need to update the system and open the Terminal shell of Ubuntu24. During both installation and upgrade processes, we need to use the command line. a simple

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous &quot;a&quot; in Ubuntu system

Java Maven build tool advancement: optimizing compilation speed and dependency management Java Maven build tool advancement: optimizing compilation speed and dependency management Apr 17, 2024 pm 06:42 PM

Optimize Maven build tools: Optimize compilation speed: Take advantage of parallel compilation and incremental compilation. Optimize dependencies: Analyze dependency trees and use BOM (bill of materials) to manage transitive dependencies. Practical case: illustrate optimizing compilation speed and dependency management through examples.

Detailed steps to install Go language on Win7 computer Detailed steps to install Go language on Win7 computer Mar 27, 2024 pm 02:00 PM

Detailed steps to install Go language on Win7 computer Go (also known as Golang) is an open source programming language developed by Google. It is simple, efficient and has excellent concurrency performance. It is suitable for the development of cloud services, network applications and back-end systems. . Installing the Go language on a Win7 computer allows you to quickly get started with the language and start writing Go programs. The following will introduce in detail the steps to install the Go language on a Win7 computer, and attach specific code examples. Step 1: Download the Go language installation package and visit the Go official website

How to configure and install FTPS in Linux system How to configure and install FTPS in Linux system Mar 20, 2024 pm 02:03 PM

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

What tool does git use to pull remote code to local? What tool does git use to pull remote code to local? Apr 09, 2024 pm 01:24 PM

Specific steps for Git to pull remote code to the local warehouse: Open Git Bash or a terminal window. Navigate to the local repository directory where you want to pull the code. Run command: git pull

See all articles