1:maven-shade-plugin 插件

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<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> <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.test.TestClient</mainClass>
</transformer> </transformers>
</configuration>
</execution>
</executions>
</plugin>

2:maven-assembly-plugin插件

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

4:参考

https://www.cnblogs.com/fuxinci/p/3356087.html

Maven工程打成一个jar包的更多相关文章

  1. 如何把一个java工程打成一个jar包(转载)

    1.jar包有入口(即有main()函数) 选中要打包的工程--->右键选择Export---->java----->Runnable java file----->next- ...

  2. Maven将代码及依赖打成一个Jar包的方式

    Maven可以使用mvn package指令对项目进行打包,如果使用java -jar xxx.jar执行运行jar文件,会出现"no main manifest attribute, in ...

  3. maven 引用另一个jar包 需要先打包在仓库里面 并在pom里面配置 才可以引用

    maven 引用另一个jar包 需要先打包在仓库里面 并在pom里面配置 才可以引用

  4. maven将项目及第三方jar打成一个jar包

    pom.xml中添加如下配置 把依赖包和自己项目的文件打包如同一个jar包(这种方式对spring的项目不支持) <build> <plugins> <plugin> ...

  5. maven工程引用外部jar包

    maven工程经常回遇到引用外部jar包,需要先安装在jar包,然后再在工程中pom.xml文件中添加依赖. 示例: 命令行中运行: mvn install:install-file -Dfile=E ...

  6. 使用IDEA的maven工程导入ojdbc14 jar包失败

    原因:ojdbc是要收费的所以maven无法通过中央仓库下载. 一开始以为是我网络不好,导致下载一直失败,可是我怎么想都不对劲,因为我自己使用了阿里云的镜像,网络不可能有问题吧,于是又使用外网,重新导 ...

  7. maven工程引入外部jar包

    pom.xml: <dependency> <groupId>new</groupId> <artifactId>new</artifactId& ...

  8. 【idea】idea如何在maven工程中引入jar包

    在pom.xml文件中引入所有代码包后,项目右键--maven--reimport </dependencies>

  9. maven工程编译成jar包

    在pom文件的project节点下增加build节点,mvn package即可 <build> <plugins> <plugin> <artifactId ...

随机推荐

  1. Mongodb 基础 数据导入导出和用户管理

    数据导出 导出命令使用方式 mongoexport---->csv/json使用 参数: -d 库名 -c 表名 -f field1,field2....列名 -q 查询条件 -o 导出文件名 ...

  2. 【LeetCode每天一题】Group Anagrams(变位词组)

    Given an array of strings, group anagrams together. Example: Input: ["eat", "tea" ...

  3. 《全栈性能Jmeter》-1性能方向职业发展

  4. 《全栈性能Jmeter》-2性能测试初体验

  5. 解决办法: RSA host key for [ip address] has changed and you have requested strict checking.

    在服务器重装后想要远程连接服务器,报错如下: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE ...

  6. iNotify.js通知JS 实现浏览器的 title 闪烁、滚动、声音提示、chrome、Firefox、Safari等系统通知。

    https://github.com/jaywcjlove/iNotify     JS 实现浏览器的 title 闪烁.滚动.声音提示.chrome.Firefox.Safari等系统通知. 这是重 ...

  7. InstallShield12的安装破解方法

    InstallShield是一个非常专业的windows程序打包工具,利用它我们可以轻松方便地将我们开发的windows程序进行封装打包.下面呢我就以我自己的实际操作经历来给大家介绍一下如何安装和破解 ...

  8. idc函数大全

    A80_addcA80_addcixA80_addciyA80_addixA80_addiyA80_cmpdA80_cmpiA80_im0A80_im1A80_im2A80_jrcA80_jrncA8 ...

  9. 兼容PC和手机触摸代码

    测试环境:unity3d 4.6.1 using UnityEngine; using System.Collections; public class neccc : MonoBehaviour { ...

  10. 进入Linux单用户模式

    1.       在启动系统出现如下画面时按Enter键进入系统设置页面: 2.       系统设置页面: 3.       按下e键进入: 4.       选择第二项,按e键进入 5.      ...