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
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.
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:
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.
Warehouse configuration
Configure the local warehouse in the settings.xml file
Mirror warehouse configuration
Set up mirror warehouse
Configure connection password
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.
Set the project name.
Setting the configuration file So
far, maven and idea have successfully integrated.