作用:

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. Python学习 Day 12 调试 断言 logging pdb pdb.set_trace

    调试 第一种方法简单直接粗暴有效,就是用print把可能有问题的变量打印出来看看: >>> def foo(s): n= int(s) print '>>> n = ...

  2. Node.js——路径问题

    相对路径问题:读取文件,形如 ./ 或者 ../  一般认为这个点是相对于这个 js 文件的文件夹路径,实际上不是,这个点相对于node命令时的当前路径,不同 js 文件下进行 ./  这样的引入是不 ...

  3. 合并百度影音的离线数据 with python 2.1 bdv格式的更新

    最近百度影音的离线下载文件,格式有新变化. 经过分析,是bdv格式又有新格式,从最初的bdv0001,到bdv.config 的file....,这次更新的格式是直接包含一个片段,其中还有使用guid ...

  4. Locations for Public Frameworks

    Locations for Public Frameworks Third-party frameworks can go in a number of different file-system l ...

  5. bootparam - 介绍Linux核心的启动参数

    描叙 Linux 核心在启动的时候可以接受指定的"命令行参数"或"启动参数".在通常情况下,由于核心有可能无法识别某些硬件,或可能将某些硬件识别为不正确的配置, ...

  6. numpy add

    在numpy中,'+' 和add 是一样的 np.add(x1, x2) x1+x2 有种特殊情况需要注意,x1和x2的shape不一样的加法: 两个shape不一样的array相加后会变成一个com ...

  7. PHP 下基于 php-amqp 扩展的 RabbitMQ 简单用例 (一) -- 安装 AMQP 扩展和 Direct Exchange 模式

    Windows 安装 amqp 扩展 RabbitMQ 是基于 amqp(高级消息队列协议) 协议的.使用 RabbitMQ 前必须为 PHP 安装相应的 amqp 扩展. 下载相应版本的 amqp ...

  8. 基于oauth2.0实现应用的第三方登录

    OAuth2 OAuth2所涉及到的对象主要有以下四个: Client 第三方应用,我们的应用就是一个Client Resource Owner 资源所有者,即用户 Authorization Ser ...

  9. 洛谷——P4053 [JSOI2007]建筑抢修

    P4053 [JSOI2007]建筑抢修 小刚在玩JSOI提供的一个称之为“建筑抢修”的电脑游戏:经过了一场激烈的战斗,T部落消灭了所有z部落的入侵者.但是T部落的基地里已经有N个建筑设施受到了严重的 ...

  10. MySQL与MyBatis中的查询记录

    1.时间段查询 MySQL:select * from table where ctime >= CURDATE() and ctime <DATE_SUB(CURDATE(),INTER ...