2018.4.16
First, before getting started, we need to understand Maven.
1. Maven model The
picture comes from the
basic concept of Maven on the Internet
- Project: Anything you want to build, Maven can consider them as a project, and these projects are identified as project model objects (Project Object Model, POM). A project can depend on other projects, and a project can also be composed of multiple sub-projects.
- POM: POM (pom.xml) is the core file of Maven, it is a metadata file that instructs how Maven works, similar to the build.xml file in Ant. POM files are located in the root directory of every project.
- GroupId: GroupId is the unique identifier of a project in the world. Generally, it is the project name. It is useful to use a full package name to distinguish a project from other similarly named projects.
- Artifact: Chinese name, component. Is the file that the project will produce or need to use, it can be a .jar file, a source file, a binary file, a .war file, or even a .pom file. Each Artifact is uniquely identified by a combination of GroupId and Artifact identifier. Artifacts that need to be used must be placed in the Repository, otherwise Maven will not be able to find them.
- Dependency: A typical Java project will depend on other packages in order to be able to build or wrap. Dependency is generally the Artifact of other projects.
- Plug-in: It can be said that Maven is a collection of plug-ins, each of its functions is completed by the plug-in, the plug-in provides goals, and completes the work according to the metadata found in the POM.
- Repository: Warehouse, where Artifact is placed, there are central warehouses, public warehouses, private warehouses, and local warehouses. Generally, in order to improve the download speed, there will be a private warehouse.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>springdemo</groupId>
<artifactId>springdemo1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springdemo1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring Core -->
<!-- http://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<!-- Spring Context -->
<!-- http://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
</dependencies>
</project>
This is a pom.xml file I wrote when I was doing the demo.