代码之家  ›  专栏  ›  技术社区  ›  Manu

如何在dist文件夹中包含所有其他jar库来生成单个jar文件

  •  -2
  • Manu  · 技术社区  · 7 年前

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

    1 回复  |  直到 7 年前
        1
  •  0
  •   Stormcloud    7 年前

    你没有告诉我们你在用什么来构建你的代码。我将猜测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>