Introduction to maven, download configuration

Introduction to Maven and download configuration

Maven is a tool dedicated to building and managing Java-related projects.

One, the main use of Maven

1. Java projects managed by Maven have the same project structure

Java projects managed with Maven all have the same project structure

  • The pom.xml configuration file is used to maintain which jar packages are used in the current project

  • All java code is placed under src/main/java

  • All test codes are placed under src/test/java

Java projects under Maven have the same project structure

2. Unified maintenance of jar packages

​ For example, there are 3 Java projects, these projects are not maven style. Then these three projects will maintain a set of jar packages. And some of the jar packages are the same.

​ For maven-style projects, first put all the jar packages in the " repository ", and then which project needs the jar package, just give the jar package name and version number. In this way, the jar package is shared

Two, Maven download and configuration

Maven download configuration tutorial

Three, warehouse

1. Warehouse concept

​ The warehouse is used to store the jar packages needed by the project. Maven uses a warehouse, multiple projects, so that multiple projects share the same jar package in a warehouse.

2. The default location of the warehouse

​ The default designated location of the warehouse is the user folder/.m2/repository under the User folder in the C drive.

Corresponding to my own computer is:

C:\Users\Devin\.m2\repository

3. Set the default download path of maven

​ By default, maven downloads jar packages from the official server provided by maven. And the official server is abroad, because everyone knows the reason, the network speed is very slow, and it is easy to get stuck.

​ In order to quickly download the relevant jar packages, you can use the domestic maven Alibaba Cloud download address:

  1. Open the following conf/settings.xml configuration file under the maven file, and my own path is as follows:

  2. Modify, add an Alibaba Cloud mirror address under mirrors (modified location is about 160-165):

    <mirror>
                <id>alimaven</id>
                <mirrorOf>central</mirrorOf>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
    

4. Modify the location of the maven warehouse

​ The default location of the warehouse is C:\Users\Devin\.m2\repository, it is a bit bad to put it on the C drive, and the system will not be reinstalled . So usually I will modify the location of the warehouse to:

D:/maven/repository

Modify line 55 of the pom.xml configuration file and modify the content in the localRepository tag.


以上为Maven的简单介绍以及基本的下载配置,之后会更新maven在Eclipse中比较具体的配置和应用,以及Java Web项目的创建和管理

Guess you like

Origin blog.csdn.net/weixin_40849588/article/details/93239717