Maven 插件之间的区别( assembly-plugins 、 jar-plugins 、 shaded-plugins ) [英] Difference between maven plugins ( assembly-plugins , jar-plugins , shaded-plugins)

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

问题描述

我是 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-插件、阴影插件)

  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 package 就会有一个 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/javasrc/main/resources/ 下的java 文件.它不包括依赖项 JAR 文件.
  2. maven-assembly-plugin:此插件将所有依赖 JAR 提取到原始类中并将它们组合在一起.它还可用于通过指定主类来构建可执行 JAR.它仅适用于依赖较少的项目;对于依赖较多的大型项目,会导致Java类名冲突.
  3. maven-shade-plugin:它将所有依赖项打包到一个 uber-JAR 中.它还可用于通过指定主类来构建可执行 JAR.这个插件特别有用,因为它合并特定文件的内容而不是通过 重定位类.当 JAR 中存在具有相同名称的资源文件并且插件尝试将所有资源文件打包在一起时,需要这样做.
  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 groups them 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 names to conflict.
  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 have the same name across the JARs and the plugin tries to package all the resource files together.

参考:比较:maven 插件 jar,assembly,shade

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

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