2016-11-16 43 views
1

我有一個maven項目。該應用程序有一個主要方法的類。我正在爲這個應用程序創建一個jar文件,它將被批量調用。批處理會調用jar文件,理論上它會用main方法查找類。但該應用程序缺少清單文件。所以我需要創建一個讓jar運行。如何創建Manifest文件到我現有的maven項目

我無法找到如何使用maven創建清單文件。我是否需要手動創建META-INF目錄和Manifest.mf文件並填寫它,或者是否存在使用Maven的自動方式?

回答

0

使用Maven-JAR-插件

<plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-jar-plugin</artifactId> 
         <version>2.4</version> 
         <configuration> 
          <archive> 
           <!-- Configures the content of the created manifest --> 
           <manifest> 
            <!-- Adds the classpath to the created manifest --> 
            <addClasspath>true</addClasspath> 
            <!-- Specifies that all dependencies of our application are found --> 
            <!-- Configures the main class of the application --> 
            <mainClass>xxx.zzz.yyy.MainClass</mainClass> 
           </manifest> 
          </archive> 
         </configuration> 

        </plugin> 

希望這會有所幫助。

相關問題