zoukankan      html  css  js  c++  java
  • maven打包插件maven-shade-plugin简单介绍

    作用:

    1、可以把依赖打入jar包,然后直接使用这个jar包,从而不用担心依赖问题

    2、通过设置MainClass,创建一个可以执行的jar包

    3、Java工程经常会遇到第三方 Jar 包冲突,使用 maven shade plugin 可以解决 jar 或类的多版本冲突。 maven-shade-plugin 在打包时,可以将项目中依赖的 jar 包中的一些类文件打包到项目构建生成的 jar 包中,在打包的时候把类重命名

    3、Resource Transformers可以对多个依赖包的冲突内容进行处理

    Merging Content of Specific Files with AppendingTransformer, XmlAppendingTransformer and ResourceBundleAppendingTransformer

    Some jars contain additional resources (such as properties files) that have the same file name. To avoid overwriting, you can opt to merge them by appending their content into one file. One good example for this is when aggregating both the spring-context and plexus-spring jars. Both of them have the META-INF/spring.handlers file which is used by Spring to handle XML schema namespaces. You can merge the contents of all the files with that specific name using the AppendingTransformer as shown below:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                      <resource>META-INF/spring.handlers</resource>
                    </transformer>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                      <resource>META-INF/spring.schemas</resource>
                    </transformer>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
    

    这篇文章的主要目的是:在做dubbo的jmeter压测的时候,你只需要把所有的依赖包打到dubbo-consumer的jar包里去,这样把这个唯一的jar包放入lib/ext下就可以了

    1、https://www.jianshu.com/p/7a0e20b30401

    2、https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer

  • 相关阅读:
    必备课程之3:Windows Server 2003 R2 高效分支机构管理体验(Level 200)
    阻止自动升级到IE7。
    最真实Cisco模拟器dynamips使用指南本人原创.
    任务部署
    在Microsoft VirtualPC虚拟机上运行SafeGuard Easy.
    广域网概念T1和CSU/DSU
    Exchange做增量备份必须关闭循环日志
    国际航班出发流程
    必备课程之4:Windows Server 2003 构建高可用性的业务平台体验(Level 350)
    IBM笔记本换硬盘步骤-转载
  • 原文地址:https://www.cnblogs.com/shengulong/p/8386619.html
Copyright © 2011-2022 走看看