描述: 我把jar命名为ingestionframework.jar,主类命名为abc_job。我在windows机器上使用eclipse maven创建了jar文件。我能用命令运行jar" java -jar ingestionframework.jar"在Windows机器上。 我将此jar转移到 Hadoop linux集群并尝试将其作为
运行" java -jar ingestionframework.jar"
这就是错误
"错误:无效或损坏了jarfile ingestionframework.jar"
When I ran same jar on linux cluster as
" java -cp ingestionframework.jar com.sp.abc_job"
然后它成功运行。 如果我在使用maven生成jar文件或我的pom.xml文件的任何其他问题时遗漏了任何内容,请告诉我
代码部分
pom.xml part for this is as below
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.sp.abc_job</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Manifest file was generated was as below:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: yogesh
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_91
Main-Class: com.sp.abc_job