maven 总结

maven 对jar包的依赖有先后顺序,用父pom 管理子pom 在父类中引用了包(dependency加入了版本号) 子类中引用的时候版本号就不需要要了

maven 用包是就近原则

eg:我父工程(sun)的pom用到了netty包引入的是

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.7.Final</version>
</dependency>
我子工程(moon-service)pom用到了netty包引入的是
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.18.Final</version>
</dependency>
则在子工程中用到的netty包的版本就是4.0.18
为了上下工程统一,则父工程用到的版本是4.1.17版本,子工程在引用的时候依赖关系的版本号就删掉即可
eg:
父工程
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.7.Final</version>
</dependency>


子工程

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
 


原文地址:https://www.cnblogs.com/austinspark-jessylu/p/7814835.html