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

Recommend

How to check PCIe version and speed in Linux

PCIE has four different specifications. Let’s tak...

Difference between MySQL btree index and hash index

In MySQL, most indexes (such as PRIMARY KEY, UNIQ...

CSS Pick-up Arrows, Catalogs, Icons Implementation Code

1. CSS Miscellaneous Icons There are three ways t...

Tutorial on building nextcloud personal network disk with Docker

Table of contents 1. Introduction 2. Deployment E...

Nginx dynamically forwards to upstream according to the path in the URL

In Nginx, there are some advanced scenarios where...

CSS to achieve scrolling image bar example code

On some websites, you can often see some pictures...

CocosCreator general framework design resource management

Table of contents Problems with resource manageme...

Introduction to HTML DOM_PowerNode Java Academy

What is DOM? With JavaScript, you can reconstruct...

Learn Hyperlink A Tag

ask: I have styled the hyperlink using CSS, but i...

How to view version information in Linux

How to view version information under Linux, incl...

How to install babel using npm in vscode

Preface The previous article introduced the insta...

Introduction to common commands and shortcut keys in Linux

Table of contents 1 System Introduction 2 System ...

Detailed process of installing nginx1.9.1 on centos8

1.17.9 More delicious, really Nginx download addr...

Linux ssh server configuration code example

Use the following terminal command to install the...