什么是胖 JAR? [英] What is a fat JAR?

查看:41
本文介绍了什么是胖 JAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说有人说他们创建了一个胖 JAR 并部署了它.它们实际上是什么意思?

I've heard people say that they create a fat JAR and deploy it. What do they actually mean ?

推荐答案

fat jar 是 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 中,可以使用 (指令):

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>

<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屋!

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