maven 依赖

依赖传递:
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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值