maven使用筆記--在父pom中聲明過的jar可以被繼承,使子項目不用寫版本號由父pom控制


將dependencies放到dependencyManagement中,如下:        

[html]  view plain copy 在CODE上查看代碼片 派生到我的代碼片
  1. <dependencyManagement>  
  2.     <dependencies>  
  3.         <dependency>  
  4.             <groupId>junit</groupId>  
  5.             <artifactId>junit</artifactId>  
  6.             <version>4.9</version>  
  7.             <scope>test</scope>  
  8.         </dependency>  
  9.     </dependencies>  
  10. </dependencyManagement>  
  11.  那么,子模塊在使用到junit的時候,只需要聲明groupId和artifactId即可,即:

    [html]  view plain copy 在CODE上查看代碼片 派生到我的代碼片
    1. <dependencies>  
    2.     <dependency>  
    3.         <groupId>junit</groupId>  
    4.         <artifactId>junit</artifactId>  
    5.     </dependency>  
    6. </dependencies>  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM