Maven study notes (two) the use of maven

introduction

The previous section of Xiaoyuan’s blog introduced how to install maven on the local computer. This section of the blog will introduce how to configure and use maven. Before mastering this knowledge, you first need to understand the working principle of maven.

How maven works

First of all, we need to understand the two core functions of maven, one-click construction of the project, why do you need one-click construction?
A project needs to go through several processes from development to construction, such as project compilation, testing, running, packaging, installation, deployment, etc. The traditional method requires each developer to manually participate in each process, the whole process is relatively cumbersome, in order to improve efficiency , Maven provides a way to build a project with one click, and its running structure is as follows: the
Insert picture description here
whole project can be easily built with one click through maven.

maven warehouse management

Maven locates the location of the maven warehouse according to the setting.xml file. Maven warehouses are divided into multiple types. Maven can use the following figure to explain the warehouse management.
Insert picture description here
First, when maven finds the jar package, it will go to the local warehouse to find it. When there is no corresponding information locally, it will go to the corporate private server or the central warehouse to find it. When the jar package is not found in the corporate private server, it will Need to go to the central warehouse to find it.

maven pom file loading

The pom file will be loaded, and the jar package management will be realized according to the dependency coordinates of the jar package. Maven manages the jar package as shown in the figure below:
Insert picture description here
According to the principle shown in the figure above, the unified management of the jar package by maven can be realized.

maven settings.xml file configuration

When configuring the local warehouse and the central warehouse, you need to modify the setting.xml file of maven.
First configure the local warehouse.
The location of Little Ape’s local warehouse.
Insert picture description here

Warehouse configuration

Configure the local warehouse in the settings.xml file
Insert picture description here

Mirror warehouse configuration

Set up mirror warehouse
Insert picture description here

Configure connection password

Insert picture description here

Integration of maven and idea

Maven needs to be integrated with idea. The integration of maven and idea is very simple. You only need to configure the maven xml file when creating the project.
Create a maven project.
Insert picture description here
Set the project name.
Insert picture description here
Setting the configuration file So
Insert picture description here
Insert picture description here
far, maven and idea have successfully integrated.

Guess you like

Origin blog.csdn.net/xueshanfeitian/article/details/108662669