依赖传递:
hongxing-bge
hongxing-nage 依赖bge 在nage的pom.xml中添加bge的坐标 需要对bge项目 进行 clean package 、install
hongxing-shanji 依赖nage 在shanji的pom.xml中添加nage的坐标 需要对nage项目 进行 clean package 、install
如果不需要bge 的
<exclusions> <!-- 不需要bge的依赖 -->
<exclusion>
<groupId>com.hongxing</groupId>
<artifactId>hongxing-bge</artifactId>
</exclusion>
</exclusions>
依赖的范围scope:
六种
compile 默认 编译测试运行都有效
provided 在编译和测试有效
runtime 在测试和运行时有效
test 只在测试有效
system 在编译和测试有效
import 导入范围,只在实用dependencyManagement中表示从其他pom导入dependency
依赖冲突
原则:1.短路优先 2.路径相同,谁先声明谁优先
聚合和继承
聚合
将最大的maven项目的
<packaging>pom</packaging>
<modules>
<module>../hongxing-bge</module>
<module>../hongxing-nage</module>
<module>../hongxing-shanji</module>
</modules>
继承
hongxing-parent pom.xml
<groupId>com.hongxing</groupId>
<artifactId>hongxing-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> 修改1
<name>hongxing-parent</name>
<url>http://maven.apache.org</url>
<properties>
<junit.version>3.8.1</junit.version> 添加2
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement> 添加3
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version> 修改4
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
子项目:
<parent> 添加
<groupId>com.hongxing</groupId>
<artifactId>hongxing-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version> 删除
</dependency>
</dependencies>