构件
pom类型常用于微服务中作为父Pom,通过 可以将子模块包含进来,共享父Pom的依赖,
GAV坐标
<classifier>:区分相同的pom但是被不同方式构建的构件,如javadoc、sources、jdk16、jdk17
依赖
<dependencies>
<dependency>
<groupId/>
<artifactId/>
<version/>
<type/>
<scope/>
<systemPath/>
dependency>
...
dependencies>
scope>的import来导入他们。
<properties>
<netty.version>4.1.9netty.version>
properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.nettygroupId>
<artifactId>netty-allartifactId>
<version>${netty.version}version>
dependency>
dependencies>
dependencyManagement>
三个内置的构建生命周期:clear、default、site,前两个用于清理和分发项目。
构建生命周期的各个阶段的部分清单:
所有的构建生命周期阶段的执行都通过插件来实现。

<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>exec-maven-pluginartifactId>
<version>1.2.1version>
plugin>
如同dependencyManagement一样,子Pom可以直接继承使用。
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-pluginartifactId>
<version>3.2version>
<configuration>
<source>1.7source>
<target>1.7target>
configuration>
plugin>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>exec-maven-pluginartifactId>
<version>1.2.1version>
plugin>
plugins>
pluginManagement>
build>
子类继承插件
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-pluginartifactId>
plugin>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>exec-maven-pluginartifactId>
plugin>
plugins>
build>
通过
可以是远程也能是本地的。
远程库通常包含了快照和发布两个区域,
如果
非SNAPSHOT结尾就是发布版本,只允许某个特定Version上传一次。
当构建SNAPSHHOT
依赖的项目是,会检查本地依赖库是否相应的版本,如果没有就会去指定的远程仓库进行检索,这时候就会拉取到最新时间戳的构件;如果本地有这个构件,且当前构建也是这一天中的第一个,那么会尝试更新本地副本。可以通过setting.xml进行设置。
包含子项目要继承的信息,当然子项目可以重写
聚合器pom会构建一个或者多个子项目。
<modules>
<module>Servermodule>
<module>Clientmodule>
modules>
<project>
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>niagroupId>
<artifactId>nia-samples-parentartifactId>
<version>1.0-SNAPSHOTversion>
parent>
<artifactId>chapter2artifactId>
<packaging>pompackaging>
<name>2. Echo Client and Servername>
<modules>
<module>Clientmodule>
<module>Servermodule>
modules>
<properties>
<echo-server.hostname>localhostecho-server.hostname>
<echo-server.port>9999echo-server.port>
properties>
<dependencies>
<dependency>
<groupId>io.nettygroupId>
<artifactId>netty-allartifactId>
dependency>
dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-pluginartifactId>
plugin>
<plugin>
<artifactId>maven-failsafe-pluginartifactId>
plugin>
<plugin>
<artifactId>maven-surefire-pluginartifactId>
plugin>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>exec-maven-pluginartifactId>
plugin>
plugins>
build>
project>
<project>
<parent>
<groupId>niagroupId>
<artifactId>chapter2artifactId>
<version>1.0-SNAPSHOTversion>
parent>
<artifactId>echo-serverartifactId>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>exec-maven-pluginartifactId>
<executions>
<execution>
<id>run-serverid>
<goals>
<goal>javagoal>
goals>
execution>
executions>
<configuration>
<mainClass>nia.echo.EchoServermainClass>
<arguments>
<argument>${echo-server.port}argument>
arguments>
configuration>
plugin>
plugins>
build>
project>


