maven依赖传递

一 传递依赖实例
nage依赖于bge,shanji依赖于nage
 
bge的pom.xml文件
   < modelVersion > 4.0.0 </ modelVersion >
 
   < groupId > com.hongxing </ groupId >
   < artifactId > hongxing - bge </ artifactId >
   < version > 0.0.1-SNAPSHOT </ version >
   < packaging > jar </ packaging >
 
   < name > hongxing - bge </ name >
   < url > http://maven.apache.org </ url >
 
   < properties >
     < project.build.sourceEncoding > UTF-8 </ project.build.sourceEncoding >
   </ properties >
 
   < dependencies >
     < dependency >
       < groupId > junit </ groupId >
       < artifactId > junit </ artifactId >
       < version > 3.8.1 </ version >
       < scope > test </ scope >
     </ dependency >
   </ dependencies >
</ project >
 
nage的pom.xml文件
   < modelVersion > 4.0.0 </ modelVersion >
 
   < groupId > com.hongxing </ groupId >
   < artifactId > hongxing - nage </ artifactId >
   < version > 0.0.1-SNAPSHOT </ version >
   < packaging > jar </ packaging >
 
   < name > hongxing - nage </ name >
   < url > http://maven.apache.org </ url >
 
   < properties >
     < project.build.sourceEncoding > UTF-8 </ project.build.sourceEncoding >
   </ properties >
 
   < dependencies >
     < dependency >
       < groupId > junit </ groupId >
       < artifactId > junit </ artifactId >
       < version > 3.8.1 </ version >
       < scope > test </ scope >
     </ dependency >
       < dependency >
               < groupId > com.hongxing </ groupId >
               < artifactId > hongxing - bge </ artifactId >
               < version > 0.0.1-SNAPSHOT </ version >
      </ dependency >
   </ dependencies >
</ project >
 
shanji的pom.xml文件
   < modelVersion > 4.0.0 </ modelVersion >
 
   < groupId > com.hongxing </ groupId >
   < artifactId > hongxing - shanji </ artifactId >
   < version > 0.0.1-SNAPSHOT </ version >
   < packaging > jar </ packaging >
 
   < name > hongxing - shanji </ name >
   < url > http://maven.apache.org </ url >
 
   < properties >
     < project.build.sourceEncoding > UTF-8 </ project.build.sourceEncoding >
   </ properties >
 
   < dependencies >
     < dependency >
       < groupId > junit </ groupId >
       < artifactId > junit </ artifactId >
       < version > 3.8.1 </ version >
       < scope > test </ scope >
     </ dependency >
      < dependency >
        < groupId > com.hongxing </ groupId >
        < artifactId > hongxing - nage </ artifactId >
        < version > 0.0.1-SNAPSHOT </ version >
     </ dependency >
   </ dependencies >
</ project >
 
二 排除依赖实例
nage依赖于bge,shanji只依赖于nage
bge和nage的pom.xml文件不变
shanji的pom.xml文件
   < modelVersion > 4.0.0 </ modelVersion >
 
   < groupId > com.hongxing </ groupId >
   < artifactId > hongxing - shanji </ artifactId >
   < version > 0.0.1-SNAPSHOT </ version >
   < packaging > jar </ packaging >
 
   < name > hongxing - shanji </ name >
   < url > http://maven.apache.org </ url >
 
   < properties >
     < project.build.sourceEncoding > UTF-8 </ project.build.sourceEncoding >
   </ properties >
 
   < dependencies >
     < dependency >
       < groupId > junit </ groupId >
       < artifactId > junit </ artifactId >
       < version > 3.8.1 </ version >
       < scope > test </ scope >
     </ dependency >
     < dependency >
        < groupId > com.hongxing </ groupId >
               < artifactId > hongxing - nage </ artifactId >
               < version > 0.0.1-SNAPSHOT </ version >
               < exclusions >
                      < exclusion >
                            < groupId > com.hongxing </ groupId >
                            < artifactId > hongxing - bge </ artifactId >
                            < version > 0.0.1-SNAPSHOT </ version >
                      </ exclusion >
               </ exclusions >
          </ dependency >
       
    </ dependencies >
</ project >

猜你喜欢

转载自cakin24.iteye.com/blog/2393431