美文网首页
maven-shade-plugin的createDepende

maven-shade-plugin的createDepende

作者: 上课睡觉觉 | 来源:发表于2017-03-19 19:36 被阅读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了,这样可以避免重复引用。

    相关文章

      网友评论

          本文标题:maven-shade-plugin的createDepende

          本文链接:https://www.haomeiwen.com/subject/pulvnttx.html