Graphical tutorial on Maven installation and configuration under Windows (including localized warehouse configuration)

Graphical tutorial on Maven installation and configuration under Windows (including localized warehouse configuration)

1. Download Maven

Maven official website: http://maven.apache.org/

Download it as a compressed file, unzip it. I downloaded version 3.5.2, and after decompression, it is as follows:


The path is: D:\Program Files\apache-maven-3.5.2

2. Configure environment variables

Add custom variable: MAVEN_HOME

The value is the decompression path just now: D:\Program Files\apache-maven-3.5.2.


MAVEN_OPTS = -Xms128m -Xmx512m (可選)

Add “;%MAVEN_HOME%\bin;” to the end of the path variable.

3. Verify whether the installation is successful

Open a command line and enter: mvn -v . If Maven related information appears, it means the installation is successful.

4. Configure local warehouse

The most direct benefit of using Maven is the unified management of jar packages. So where are these jar packages stored? They are in your local repository, and the default address is in the C:\Users\username.m2 directory (of course, you can also modify this default address). Let's modify this default address.

In fact, we can understand the local warehouse as a "cache" to store jar packages. When developing a project, the project will first obtain the jar package from the local warehouse. When the specified jar package cannot be obtained, the local warehouse will download the jar package from the remote warehouse (or central warehouse) and "cache" it in the local warehouse for future use.

The remote repository (central repository) is officially provided by Maven and can be accessed through http://search.maven.org/. In this way, the local warehouse will grow larger as the projects accumulate. The following picture can clearly express the relationship between projects, local repositories, and remote repositories.


Now that Maven is installed, the local repository is also available, and the default path is in our C drive directory. But the C drive is always dangerous, so how to modify this default configuration.

Open the Maven installation directory\conf\setting.xml file.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 <!-- localRepository
  | The path to the local repository maven will use to store artifacts.
  |
  | Default: ${user.home}/.m2/repository
 <localRepository>/path/to/local/repo</localRepository>
 -->
 <localRepository>E:\Maven_Repo</localRepository>
 ...
 </settings>

Then the default local warehouse location has been changed to the E:\Maven_Repo directory.

It is best to create this directory manually first.

5. Check whether the settings just now are effective

Command line input: mvn help:system

If there are no problems, the configuration is successful. Now let's go to the E:\Maven_Repo directory and find that there are many more files in this directory. These are the files that Maven downloaded from the central repository.


Summarize

The above is the graphic tutorial of Maven installation and configuration under Windows (including localized warehouse configuration) introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time!

You may also be interested in:
  • Detailed steps for installing IDEA and configuring Maven
  • A brief discussion on solutions to Maven installation and environment configuration errors
  • Detailed tutorial on installing and configuring Maven on Mac and configuring it in IDEA
  • Maven installation and configuration graphic tutorial
  • Detailed installation and configuration of eclipse maven plugin
  • Maven installation and configuration in IDEA graphic tutorial
  • Detailed explanation of Maven installation, configuration and use

<<:  Detailed explanation of the working principle and solution of Js modularization

>>:  mysql5.7.21.zip installation tutorial

Blog    

Recommend

CSS sets the box container (div) height to always be 100%

Preface Sometimes you need to keep the height of ...

Implementation of Docker deployment of Tomcat and Web applications

1. Download docker online yum install -y epel-rel...

How to change the domestic image source for Docker

Configure the accelerator for the Docker daemon S...

HTML tutorial, understanding the optgroup element

Select the category selection. After testing, IE ...

How to modify port 3389 of Windows server 2008 R2 remote desktop

The default port number of the Windows server rem...

Ubuntu 19.10 enables ssh service (detailed process)

It took me more than an hour to open ssh in Ubunt...

Vue keeps the user logged in (various token storage methods)

Table of contents How to set cookies Disadvantage...

Implementation of Nginx configuration Https security authentication

1. The difference between Http and Https HTTP: It...

CSS code to achieve background gradient and automatic full screen

CSS issues about background gradient and automati...

How to wrap HTML title attribute

When I was writing a program a few days ago, I wan...

How to quickly delete all tables in MySQL without deleting the database

This article uses an example to describe how to q...

MySQL 8.x msi version installation tutorial with pictures and text

1. Download MySQL Official website download addre...

MySQL 8.0.20 installation and configuration detailed tutorial

This article shares with you a detailed tutorial ...