2016-11-16 98 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> 

希望这会有所帮助。

相关问题