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