什么是胖JAR? [英] What is a fat JAR?
本文介绍了什么是胖JAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我听说有人说他们创建了一个胖JAR并进行部署。它们实际意味着什么?
I've heard people say that they create a fat JAR and deploy it. What do they actually mean ?
推荐答案
胖罐是jar,它包含来自所有库的类,您的项目在其上取决于,当然还有当前项目的类。
The fat jar is the jar, which contains classes from all the libraries, on which your project depends and, of course, the classes of current project.
在不同的构建系统中,fat jar的创建方式不同,例如,在Gradle中,将创建它(指令):
In different build systems fat jar is created differently, for example, in Gradle one would create it with (instruction):
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'com.example.Main'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
在Maven这是以这种方式完成的(在设置常规jar之后):
In Maven it's being done this way (after setting up regular jar):
<pluginrepositories>
<pluginrepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginrepository>
</pluginrepositories>
<!-- ... -->
<plugin>
<groupid>org.dstovall</groupid>
<artifactid>onejar-maven-plugin</artifactid>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<onejarversion>0.97</onejarversion>
<classifier>onejar</classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
这篇关于什么是胖JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文