Introduction to the POM---官方文档
1、pom.xml文件,先声明project相关信息,然后声明jar放在那些仓库里,<repositories><repository>均有结束标签,其次会有<dependencies><dependency>,即此项目跑起来需要哪些文件。需要的文件均在仓库里。某些重复使用的信息可以定义在properties里面,这样在使用的地方可以通过${project.groupId}类似格式使用。
- <properties>
- <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
- </properties>
2、maven project
<groupId/>project的唯一区别标志eg. org.apache.maven <artifactId/>和groupid一起区别project,在maven生成的jar或者tar.gz时,名称即为groupid加上artifactid。 <version/>当前artifact版本 <packaging/>
3、repository[仓库] 与pluginRepository子标签一样。
| Element | Type | Description |
|---|---|---|
| uniqueVersion | boolean | Whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time Default value is: true. |
| releases | RepositoryPolicy | How to handle downloading of releases from this repository. |
| snapshots | RepositoryPolicy | 子标签<enabled>为true表示而使用快照版本的模块,在不更改版本号的情况下,直接编译打包时,maven会自动从镜像服务器上下载最新的快照版本。 |
| id | String | 仓储的唯一标识 |
| name | String | 人类可以看懂的名字 |
| url | String | 仓储URL |
| layout | String | The type of layout this repository uses for locating and storing artifacts - can be legacy or default. Default value is: default. |
repository是配置远程仓的,pluginRespository是其他仓库,我知道本地仓库没有对应的jar包时会使用远程仓库,然后下载对应jar,所以在repository可以配置这个远程仓库的信息
4、dependency[依赖]
| Element | Type | Description |
|---|---|---|
| groupId | String | The project group that produced the dependency, e.g. org.apache.maven. |
| artifactId | String | The unique id for an artifact produced by the project group, e.g. maven-artifact. |
| version | String | The version of the dependency, e.g. 3.2.1. In Maven 2, this can also be specified as a range of versions. |
| scope | String | The scope of the dependency - compile, runtime, test, system, and provided. Used to calculate the various classpaths used for compilation, testing, and so on. It also assists in determining which artifacts to include in a distribution of this project. For more information, seethe dependency mechanism. |
5、build 》》plugins》》plugin。每个plugin里是groupid、artifactid、version、configuration、extensions等。extensions》》extension。
6、resources》》resource,指明路径。(许多)这个元素描述所有的类路径资源如属性文件。这些资源通常包括在最后的包装中。默认值是src/main/resources
浙公网安备 33010602011771号