如何制作包含dist文件夹中所有其他jar库的单个jar文件

时间:2017-11-24 16:39:53

标签: java jar

我创建了一个应用程序。在这个应用程序中,我怀疑在获取输出时我需要包含lib(包含所有支持jar文件的库文件夹)但我需要在一个jar文件中必须包含所有支持jar。可能吗?我正在使用Netbeans。

1 个答案:

答案 0 :(得分:0)

您没有告诉我们您使用什么来构建代码。我要猜maven(因为我知道答案是在Maven!)。你需要的是:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeScope>runtime</includeScope>
                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <!-- Add your other plug-ins here -->

    </plugins>
</build>