在Maven中将单独的jar文件打包为war文件

时间:2019-01-02 13:06:00

标签: maven package war

我已经使用Java创建了一个Web应用程序。根据设计,我为该Web应用程序创建了一个插件。 当我发布软件包时,我想将该插件的jar文件打包到“ WEB-INF / lib”目录中。 我只是手动复制jar文件。取而代之的是,有没有能力使用Maven处理这些事情? 我不想将插件作为依赖项添加到Web应用程序中。

1 个答案:

答案 0 :(得分:2)

您可以在Maven War插件中指定它。请参见下面。

jar文件-> jarfile.jar

jar文件路径-> jarFilePath(参考基本目录)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <webResources>
            <!--jarfile.jar file in to the WEB-INF/lib folder -->
            <resource>
                <directory>jarFilePath</directory>
                <includes>
                    <include>jarfile.jar</include>
                </includes>
                <targetPath>WEB-INF/lib</targetPath>
            </resource>
        </webResources>
    </configuration>
</plugin>
相关问题