【Maven】6-pom文件说明

导读:本篇文章讲解 【Maven】6-pom文件说明,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

1.常用元素介绍

<project>
	<!-- 指定了当前pom的版本 --> 
	<modelVersion>4.0.0</modelVersion>
	
	<groupId>反写的公司网址+项目名</groupId>
	<artifactId>项目名+模块名</artifactId>
	
	<!-- 第一个0表示大版本号
		  第二个0表示分支版本号
		  第三个0表示小版本号
		  0.0.1
		  snapshot快照
		  alpha内部测试
		  beta公测
		  Release稳定
		  GA正式发布
	-->
	<version>0.0.1</version>
	
	<!-- 默认是jar
	  war zip pom
	-->
	<packaging>jar</packaging>
	
	<!-- 项目描述名 -->
	<name></name>
	
	<!-- 项目地址 -->
	<url></url>
	
	<!-- 项目描述 -->
	<description></description>
	<developers></developers>
	<licenses></licenses>
	<organization></organization>
	
	<!-- 用于管理统一参数 -->
	<properties>
		<junit.version>3.8.1</junit.version>
	</properties>
	
	<dependencies>
		<dependency>
			<groupId></groupId>
			<artifactId></artifactId>
			<version></version>
			<type></type>
			<!-- 依赖范围 -->
			<scope>test</scope>
			<!-- 设置依赖是否可选-->
			<optional></optional>
			<!-- 排除依赖传递列表 -->
			<exclusions>
				<exclusion></exclusion>
			</exclusions>
		</dependency>
		
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		
	</dependencies>
	
	<!-- 依赖的管理 -->
	<dependencyManagement>
		<dependencies>
			<dependency></dependency>
		</dependencies>
	</dependencyManagement>
	
	<build>
		<!-- 插件列表 -->
		<plugins>
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>8.1.16.v20140903</version>
				<executions>
					<execution>
						<!-- 在打包成功后使用jetty:run来运行jetty服务 -->
						<phase>package</phase>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	
	<!-- 用于集成 -->
	<parent>
		<groupId>com.hongxing</groupId>
		<artifactId>hongxing-parent</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	
	<!-- 用于聚合 -->
	<modules>
		<!-- 此处值为项目名称 -->
		<module>../hongxing-bge</module>
		<module>../hongxing-nange</module>
		<module>../hongxing-shanji</module>
	</modules>	
</project>

2.依赖范围

  • compile:默认的范围,编译测试运行都有效
  • provided:在编译和测试时有效
  • runtime: 在测试和运行中有效
  • test:只在测试时有效
  • system:与本机系统相关联,可移植性差
  • import:导入的范围,它只使用在dependencyManagement中,表示从其他的pom中导入dependecy的配置

3.依赖冲突

3.1短路优先,选取依赖路径短的

A – > B – > C – > X(jar)
A – > D – > X(jar)

3.2先声明先优先

路径长度相同,则谁先声明,先解析谁

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由半码博客整理,本文链接:https://www.bmabk.com/index.php/post/117337.html

(0)

相关推荐

发表回复

登录后才能评论
半码博客——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!