2016-09-27 18 views
0

war有一個非常標準的目錄結構Tomcat 7部署,並含有LIB等不同唯一一個WEB-INF目錄是,我有一個webstart作爲我的應用程序的一部分,坐落在一個在webstart目錄在戰爭的頂部(與WEB-INF相同)。裏面是jnlp配置以及一個lib目錄,其中只包含webstart的JAR依賴關係(與web應用使用的那些在WEB-INF/lib中相反),以便它們處於可下載路徑,就像我的javascript,css等等。當然,主Web應用程序的jar依賴不需要在可下載的路徑中,所以WEB-INF/lib在那裏工作。如何在WEB-INF/lib之外打包JNLP可下載JAR?

由於我無法在WAR構建中包含webstart及其庫,而是不存在,但是一旦部署了WAR,另一個腳本就會非常優雅地將webstart目錄注入到部署的應用程序目錄中webstart以及依賴關係。

我該如何生成一個包含JNLP的WAR以及它在可下載路徑中的lib依賴關係,這樣一旦戰爭被無縫部署,它們就會全部存在?

相關:Why can't I pack certain JARs outside WEB-INF

回答

2

您可以使用Maven Dependency Plugin with the copy-dependencies goal,如下圖所示。在這裏,您必須在<artifactItem>標籤內逐個指定所有工件。
此外,使用<outputDirectory>標記來指定要將這些工件複製到的位置。

<project> 
    [...] 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <version>2.10</version> 
     <executions> 
      <execution> 
      <id>copy</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy</goal> 
      </goals> 
      <configuration> 
       <artifactItems> 
       <artifactItem> 
        <groupId>[ groupId ]</groupId> 
        <artifactId>[ artifactId ]</artifactId> 
        <version>[ version ]</version> 
        <type>[ packaging ]</type> 
        <classifier> [classifier - optional] </classifier> 
        <overWrite>[ true or false ]</overWrite> 
        <outputDirectory>[ output directory ]</outputDirectory> 
        <destFileName>[ filename ]</destFileName> 
       </artifactItem> 
       <artifactItem> 
        <groupId>[ groupId ]</groupId> 
        <artifactId>[ artifactId ]</artifactId> 
        <version>[ version ]</version> 
        <type>[ packaging ]</type> 
        <classifier> [classifier - optional] </classifier> 
        <overWrite>[ true or false ]</overWrite> 
        <outputDirectory>[ output directory ]</outputDirectory> 
        <destFileName>[ filename ]</destFileName> 
       </artifactItem> 
       .... 
       .... Specify all the artifacts like mentioned above that you want to copy to a specified location 

       </artifactItems> 
       <!-- other configurations here --> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 
    [...] 
</project> 

您還可以查看Webstart Maven Plugin