What is an uber jar?

2018-12-31 19:02发布

I am reading Maven documentation and came across the name 'uber-jar'.

What does an uber-jar mean and what are its features/advantages?

标签: maven uberjar
4条回答
查无此人
2楼-- · 2018-12-31 19:12

Paxdiablo definition is really good.

In addition, please consider delivering an uber-jar is sometimes quite interesting, if you really want to distribute a software and don't want customer to have to download dependencies by themselves. As a draw back, if their own policy don't allow usage of some library, or if they have to bind some extra-components (slf4j, system compliant libs, arch specialiez libs, ...) this will probably increase difficulties for them.

You can perform that :

A cleaner solution is to provide thir library separately; maven-shade-plugin has preconfigured descriptor for that. This is not more complicated to do (with maven and its plugin).

Finally, a really good solution is to use an OSGI Bundle. There is plenty of good tutorials on that :)

For further configuration, please read those topics :

查看更多
长期被迫恋爱
3楼-- · 2018-12-31 19:16

ubar jar is also known as fat jar i.e. jar with dependencies.
There are three common methods for constructing an uber jar:

  1. Unshaded: Unpack all JAR files, then repack them into a single JAR. Works with Java's default class loader. Tools maven-assembly-plugin
  2. Shaded: Same as unshaded, but rename (i.e., "shade") all packages of all dependencies. Works with Java's default class loader. Avoids some (not all) dependency version clashes. Tools maven-shade-plugin
  3. JAR of JARs: The final JAR file contains the other JAR files embedded within. Avoids dependency version clashes. All resource files are preserved. Tools: Eclipse JAR File Exporter

for more

查看更多
梦该遗忘
4楼-- · 2018-12-31 19:19

Über is the German word for above or over, as in a line from a previous national anthem: Deutschland, Deutschland, über alles (Germany, Germany above all else).

Hence, in this context, an uber-jar is an "over-jar", one level up from a simple "jar", defined as one that contains both your package and all its dependencies in one single JAR file. The name can be thought to come from the same stable as ultrageek, superman, hyperspace, and metadata, which all have similar meanings of "beyond the normal".

The advantage is that you can distribute your uber-jar and not care at all whether or not dependencies are installed at the destination, as your uber-jar actually has no dependencies.

All the dependencies of your own stuff within the uber-jar are also within that uber-jar. As are all dependencies of those dependencies. And so on.

查看更多
姐姐魅力值爆表
5楼-- · 2018-12-31 19:20

A self-contained, executable Java archive. In the case of WildFly Swarm uberjars, it is a single .jar file containing your application, the portions of WildFly required to support it, an internal Maven repository of dependencies, plus a shim to bootstrap it all. see this

查看更多
登录 后发表回答