如何把依赖的jar包中的资源抽到当前jar中

maven-compiler-plugin:编译插件,可指定资源jdk版本,前提是当前代码使用的jdk版本 大于或等于 source

maven-assembly-plugin:组装插件,这个插件功能很多,可以直接生成可执行jar,这里仅用来抽取依赖jar中的资源到当前jar包 (jar-with-dependencies)

maven-shade-plugin:配合maven-assembly-plugin插件jar-with-dependencies情况,可过滤依赖jar包及资源,如我只要其中几个jar包,可使用includes,不要的jar包可excludes,还可以exclude打包后的部分目录,如maven的配置


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin> <plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default. -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!--<descriptors>-->
<!--<descriptor>/assembly/assembly.xml</descriptor>-->
<!--</descriptors>-->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<!--<minimizeJar>true</minimizeJar>-->
<artifactSet>
<includes>
<include>com.jd.xx:xx-model</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
<!--<filters>-->
<!--<filter>-->
<!--<artifact>com.jd.xx:xx-model</artifact>--> <!--<includes>-->
<!--<include>com/jd/xx/model</include>-->
<!--</includes>-->
<!--</filter>-->
<!--</filters>-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

maven打包插件的更多相关文章

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

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

  2. Maven打包插件Assembly(七)

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

  3. springboot maven打包插件

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

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

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

  5. maven打包插件详解

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

  6. maven打包插件:appassembler

    1.打包成bat 打包命令:mvn clean package appassembler:assemble <plugin> <groupId>org.codehaus.moj ...

  7. maven打包插件maven-shade-plugin简单介绍

    作用: 1.可以把依赖打入jar包,然后直接使用这个jar包,从而不用担心依赖问题 2.通过设置MainClass,创建一个可以执行的jar包 3.Java工程经常会遇到第三方 Jar 包冲突,使用 ...

  8. maven打包springboot项目的插件配置概览

    jar包的术语背景: normal jar: 普通的jar,用于项目依赖引入,不能通过java -jar xx.jar执行,一般不包含其它依赖的jar包. fat jar: 也叫做uber jar,是 ...

  9. MAVEN打包同时引入本地jar包

    方法一(pom文件指定jar包目录进行引入) 1.将需要手动引入的包放在项目目录下,如lib目录下: 修改pom文件,引入依赖并且将scope设置为system 2.同时配置maven打包插件 方法二 ...

随机推荐

  1. 使用Navicat连接MySQL8.0版本报1251错误

    出现1251错误是因为,MySQL8.0版本改变了密码的验证规则caching_sha2_password,MySQL之前的版本验证规则是mysql_native_password,现在需要修改MyS ...

  2. Processing 网格(棋盘格)无限偏移纹理动画

    过火 再度出击!这次我们要玩得更火一点---把静帧变动画.没错,将棋盘格动起来!看一下效果: 这是一个经典的无限偏移动画,在很多2d横版射击游戏中都会采用的技术.如何在Processing中实现,有两 ...

  3. Codeforces Round #672 (Div. 2) A - C1题解

    [Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...

  4. springmvc 源码分析(二)-- DiapartcherServlet核心调用流程分析

    测试环境搭建: 本次搭建是基于springboot来实现的,代码在码云的链接:https://gitee.com/yangxioahui/thymeleaf.git 项目结构代码如下: 一: cont ...

  5. 对于filter的理解

    filter语法:使用filter会创建一个新数组,所以原数组不变 array.filter(function(value,index,arr), thisValue) 其中:arr:数组(可选) i ...

  6. (转载)什么是B+树?

    本文转载自网络. 如有侵权,请联系处理!  

  7. Hyper-V Server + Windows Admin Center

    2020年的十一黄金周是双节,偶然间得知再出现双节可能要几十年之后了,很可惜我并没有出去游玩的打算.所以假期没什么事,就来研究下Hyper Server + Windows Admin Center. ...

  8. matlab中fseek 移至文件中的指定位置

    文章来源:https://ww2.mathworks.cn/help/matlab/ref/fseek.html?searchHighlight=fseek&s_tid=doc_srchtit ...

  9. .NET 云原生架构师训练营(模块一 架构师与云原生)--学习笔记

    目录 什么是软件架构 软件架构的基本思路 单体向分布式演进.云原生.技术中台 1.1 什么是软件架构 1.1.1 什么是架构? Software architecture = {Elements, F ...

  10. Swoole实时任务异步调用Demo

    server.php <?php class Server { private $serv; private $logFilePath = "/data/wwwroot/houtai/ ...