maven插件之间的区别(汇编插件,jar插件,阴影插件) [英] Difference between maven plugins ( assembly-plugins , jar-plugins , shaded-plugins)

查看:228
本文介绍了maven插件之间的区别(汇编插件,jar插件,阴影插件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是maven的初学者,现在我对这些maven插件之间的区别感到困惑。这些都是创建jar文件吗?现在我的问题是

I am a beginner in maven and now I'm confused with the difference between these maven plugins. Is these all create jar files? now my questions are


  1. 每个插件中创建的jar之间的区别是什么。(程序集插件,jar-plugin,着色插件) )

  1. what's the difference between the jar created in each plugins.( assembly plugin, jar-plugin, shaded plugin)

每个插件的目的。 (程序集,jar插件,阴影插件)

The purpose of each plugin. ( assembly, jar plugin, shaded plugin )

我知道即使没有指定任何这些插件,一旦输入mvn包就会有一个jar输出。没有这些插件的输出jar和带有这些插件的输出jar有什么区别? TIA

I know even without specifying any of these plugins once type mvn package there will be a jar output. What is the difference of the output jar without these plugins and the output jar with these plugins?. TIA


推荐答案


  1. maven-jar-plugin :此插件提供了构建和签名jar的功能。但它只是编译src / main / java和/ src / main / resources /下的java文件。它不包含依赖项JAR文件。

  2. maven-assembly-plugin :此插件将所有依赖项jar提取到原始类中,并将它组合在一起。它还可以通过指定主类来构建可执行jar。它适用于仅具有较少依赖性的项目,对于具有许多依赖项的大型项目,它将导致Java类名冲突问题。

  3. maven-shade-plugin :它将所有依赖项打包到一个超级jar中。它还可以通过指定主类来构建可执行jar。这个插件特别有用,因为它合并特定文件的内容而不是通过重新安置课程。当资源文件在jars中具有相同的名称且插件尝试打包所有资源文件时,需要这样做。

  1. maven-jar-plugin: This plugin provides the capability to build and sign jars. But it just compiles the java files under src/main/java and /src/main/resources/. It doesn't include the dependencies JAR files.
  2. maven-assembly-plugin: This plugin extracts all dependency jars into raw classes, and group it together. It can also be used to build an executable jar by specifying the main class. It works in project with less dependencies only, for large project with many dependencies, it will cause Java class name conflict issue.
  3. maven-shade-plugin: It packages all dependencies into one uber-jar. It can also be used to build an executable jar by specifying the main class. This plugin is particularly useful as it merges content of specific files instead of overwriting them by Relocating Classes. This is needed when there are resource files that are have the same name across the jars and the plugin tries to package all the resource files.

参考:比较:maven插件罐,装配,阴影

这篇关于maven插件之间的区别(汇编插件,jar插件,阴影插件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆