maven-shade-plugin的createDepende

2017-03-19  本文已影响0人  上课睡觉觉

maven-shade-plugin插件有个配置属性:createDependencyReducedPom,默认值为true.

当这个属性为true的时候,如果我们使用maven-shade-plugin来打包项目,那么便会在项目根目录下生成一个dependency-reduced-pom.xml文件,这个被删减的pom文件会移除已经打包进jar包中的依赖。

怎么理解呢,也就是说,假如我的一个工程A依赖了spring-boot-starter-tomcat,那么这个依赖(即spring-boot-starter-tomcat)中的.class文件会被打包进生成的A.jar包中,

<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>

而在生成的dependency-reduced-pom.xml文件中,这个依赖将被exclusion掉。

那么这个dependency-reduced-pom.xml有什么用呢?
我们如果在另一个工程B中引用了A工程对应的A.jar,而且B也依赖了spring-boot-starter-tomcat,那么我们在B工程中就不需要再依赖spring-boot-starter-tomcat了,这样可以避免重复引用。

上一篇下一篇

猜你喜欢

热点阅读