Maven中的pom.xml

pom.xml中<version></version>
第一个0表示大版本号,第二个0表示分支版本号,第三个零表示小版本号
0.0.1(snapshot 快照 )(alpha 内部测试) (beta 公测) (release 稳定) (GA 正式发布版本)
<packaging>打包的方式,默认是.jar,其他如pom</packaging>
<name>生成文档时,项目的描述名</name>
<url>项目地址</url> ,许可证,组织等信息
<properties>
<project.build.sorceEncoding>UTF-8</>
<junit.version></><!--下面引用的时候就可以使用${junit.version}-->
</properties>


依赖列表:
<dependencies>
<dependency>
<scope>依赖范围,如test</scope>
<option>设置依赖是否可选,默认为false </option>
<exclusion>排除依赖传递的列表</exclusion>
</dependency>

</dependencies>




对构件的行为提供支持
<build>
插件列表:
<plugins>
<plugin>
提供groupId等
若打包的时候运行插件,则:
<execution>
<phase>
package 指定阶段
</phase>
<goals>run</goals> 运行目标
</execuyion>
</plugin>
</plugins>

</build>

子模块对父模块的pom的继承
<parent>父模块的坐标</parent>

聚合多个module项目,一起进行编译: clean install
<modules></modules>

继承,如Junit的配置
依赖管理:一般用于父模块的设置,子模块实行继承
<dependencyManagemet>
<dependency></dependency>
</dependencyManagemet>
此不会在父模块中运行

 

依赖范围:编译,测试,运行,3种classpath
<scope></scope>
属性:compile(3种)
provide,system(两者在运行时无效)
runtime在测试和运行有效
test(测试,如Junit)
import(在<dependencyManagemet>标签中,表示从其他pom中继承过来的依赖)


依赖传递:
如B依赖A,则在B中加入依赖后
A先执行clean intall
B后执行compile

依赖冲突:
A,B 依赖了不同版本的相同的构件
对于依赖于A,B的C来说,究竟是依赖了A和B哪个版本的构件
有两个原则:
(1)短路优先
(2)先声明先优先

 

官方网址:maven.apache.org

posted on 2017-03-29 17:05  LastDance  阅读(174)  评论(0编辑  收藏  举报

导航