1.POM文件添加jar包生成插件

            <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
<!-- 是否指定项目classpath下的依赖 -->
<addClasspath>true</addClasspath>
<!-- 指定依赖的时候声明前缀 -->
<classpathPrefix>./lib/</classpathPrefix>
<!--依赖是否使用带有时间戳的唯一版本号,如:xxx-1.3.0-20121225.012733.jar-->
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>

2.添加第三方依赖打包插件

            <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

3.添加assembly打包插件

            <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<!-- 配置执行器 -->
<execution>
<id>make-assembly</id>
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
<configuration>
<finalName>${project.name}</finalName>
<!--配置描述文件路径-->
<descriptor>assembly.xml</descriptor>
</configuration>
</execution>
</executions>
</plugin>

4.添加打包描述文件assembly.xml

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>dropwizard-package</id>
<!--打包格式-->
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<!--导入指定文件到tar.gz包-->
<fileSet>
<directory>${project.basedir}/target</directory>
<outputDirectory>./${project.name}</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/target/lib</directory>
<outputDirectory>./${project.name}/lib</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>./${project.name}/conf</outputDirectory>
<directoryMode>0775</directoryMode>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
</assembly>

5.Over!!!

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

  1. Maven打包插件Assembly(七)

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

  2. maven打包插件

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

  3. maven打包插件详解

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

  4. springboot maven打包插件

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

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

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

  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. eclipse使用profile完成不同环境的maven打包功能

    原文:https://blog.csdn.net/duan9421/article/details/79086335 我们在日常开发工作中通常会根据不同的项目运行环境,添加不同的配置文件,例如 开发环 ...

随机推荐

  1. 【C++】string::find函数

    int vis=a.find(b):从string a开头开始查找第一个遇到的string b,返回string a中所匹配字符串的第一个字符的下标位置,找不到则返回-1. int vis=a.fin ...

  2. Amazon S3

    Amazon S3 是什么? Amazon S3 是亚马逊推出的一款存储服务,名为 Amazon Simple Storage Service,即亚马逊简单存储服务. 有些 S3 的概念需要了解一下: ...

  3. 分享我的GD32F450的IAP过程

    最近一个项目使用GD32F450VI+ESP8266需要做远程升级,基本参考正点原子IAP的那一章节,但是在GD32F450上却遇到了问题,无法跳转,然后使用正点原子的开发板stm32f429,以及s ...

  4. 约会安排 HDU - 4553(线段树区间查询,区间修改,区间合并)

    题目: 寒假来了,又到了小明和女神们约会的季节.  小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会.与此同时,也有很多基友找他开黑, ...

  5. 《机器学习技法》---AdaBoost算法

    1 AdaBoost的推导 首先,直接给出AdaBoost算法的核心思想是:在原数据集上经过取样,来生成不同的弱分类器,最终再把这些弱分类器聚合起来. 关键问题有如下几个: (1)取样怎样用数学方式表 ...

  6. 记一次上线部分docker不打日志的问题排查

    一次正常的上线,发了几台docker后,却发现有的机器打了info.log里面有日志,有的没有.排查问题开始: 第一:确认这台docker是否有流量进来,确认有流量进来. 第二:确认这台docker磁 ...

  7. .netcore持续集成测试篇之web项目验收测试

    系列目录 通过前面的单元测试,我们能够保证项目的基本模块功能逻辑是正常的,通过集成测试能够保证接口的请求是正常的.然而最终项目交付我们还需要对项目进行页面的行为进行测试,比如页面布局是否正常,按钮是否 ...

  8. 基于Springboot的BaseService和BaseController

    基于Springboot的BaseService,BaseController 前言: 在做项目时需要对大量的表做增删查改,而其中的逻辑大同小异,所以抽象了一个 BaseService,BaseCon ...

  9. Python模块之pexpect

    一.pexpect模块介绍 Pexpect使Python成为控制其他应用程序的更好工具.可以理解为Linux下的expect的Python封装,通过pexpect我们可以实现对ssh,ftp,pass ...

  10. HBase 系列(二)—— HBase 系统架构及数据结构

    一.基本概念 一个典型的 Hbase Table 表如下: 1.1 Row Key (行键) Row Key 是用来检索记录的主键.想要访问 HBase Table 中的数据,只有以下三种方式: 通过 ...