作用:

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

maven打包插件maven-shade-plugin简单介绍的更多相关文章

  1. maven打包插件详解

    maven-jar-plugin插件的使用及详解 该插件的xml配置及详解如下: <plugin> <groupId>org.apache.maven.plugins</ ...

  2. 有时间研究一下Maven打包插件细节

    Maven工作分为多个阶段,具体阶段参考:https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html ...

  3. maven打包插件

    如何把依赖的jar包中的资源抽到当前jar中 maven-compiler-plugin:编译插件,可指定资源jdk版本,前提是当前代码使用的jdk版本 大于或等于 source maven-asse ...

  4. 在cmd命令行使用Maven Archetype插件 generate命令创建简单的java web项目

    前提: 1.下载apache-maven:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache ...

  5. maven打包插件maven-assembly-plugin

    1.POM文件添加jar包生成插件 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifac ...

  6. Maven打包插件Assembly(七)

    1. 在 dubbo 的 provider 项目(实现类项目dubbo-service-impl)中 pom.xml 配置 assembly插件信息 <!-- 指定项目的打包插件信息 --> ...

  7. Maven仓库—Nexus环境搭建及简单介绍

    1.    环境搭建 1.1  下载 http://www.sonatype.org/nexus/ NEXUS OSS [OSS = Open Source Software,开源软件--免费] NE ...

  8. Maven仓库-Nexus环境搭建及简单介绍

    1.    环境搭建 1.1  下载 http://www.sonatype.org/nexus/ NEXUS OSS [OSS = Open Source Software,开源软件——免费] NE ...

  9. springboot maven打包插件

    <build> <plugins> <!-- springboot maven打包--> <plugin> <groupId>org.spr ...

随机推荐

  1. 解决windows下rstudio安装playwith包报错问题

    一.playwith包简介 playwith包提供了一个GTK+图形用户界面(GUI),使得用户可以编辑R图形并与其交互.playwith()函数允许用户识别和标注点.查看一个观测所有的变量值.缩放和 ...

  2. 关于NSCELL

    作为一个初学者,我一直很弄不明白NSCell的子类,比如,NSButtonCell,NSImageCell及其对应的控件之间的关系.今天,在做一个TableView实现的时候,我终于开始有点悟了——好 ...

  3. Zed Shaw:程序员的常见健康问题

    Zed Shaw:程序员的常见健康问题 原文作者Zed Shaws是一位作家.软件开发人员.音乐人(下文中提到吉他手),于2010年发布<Learn Python The Hard Way> ...

  4. lua 之 三木运算符

    在c语言中我三目运算符这么写: a?b:c 例如: max = a>b?a:b; 在lua中我们这么写 max = a>b and a or b 运行如下:

  5. 流行-Manifold【0】-维基百科中文版本解释

  6. 新引入thinkphp报错“应用目录[./Application/]不可写,目录无法自动生成! 请手动生成项目目录~”

    新引入thinkphp报错“应用目录[./Application/]不可写,目录无法自动生成! 请手动生成项目目录~”, 其主要原因是文件夹的权限问题,手动将项目文件夹权限更改为可读可写就OK,具体操 ...

  7. 自动下载相对应的jar包

    一.去到需要的 maven下载地址 http://mvnrepository.com/artifact/org.apache.struts/struts2-core/2.5.13 二.然后去到 pom ...

  8. Ztree勾选节点后取消勾选其父子节点

    前言: Ztree官方给的API可以设置勾选一个节点的同时勾选子节点或者父节点,也可以设置不影响父子节点,即将chkboxType设置为{"Y":"",&quo ...

  9. [Python3网络爬虫开发实战] 1.3.1-lxml的安装

    lxml是Python的一个解析库,支持HTML和XML的解析,支持XPath解析方式,而且解析效率非常高.本节中,我们了解一下lxml的安装方式,这主要从Windows.Linux和Mac三大平台来 ...

  10. ubuntu server 12.04.4安装配置

    这里讲