gpt4 book ai didi

java - 在 Jar 中使用第 3 方依赖项运行映射缩减作业

转载 作者:行者123 更新时间:2023-12-02 04:49:48 25 4
gpt4 key购买 nike

我正在尝试测试是否可以将第 3 方依赖项 jar 到我的 jar 中,将 jar 通过 SSH 连接到远程计算机,然后运行映射缩减作业。

流程:

在我的项目中,我运行 mvn clean package 并生成文件 my-appy-1.0-SNAPSHOT.jaroriginal-my-appy- 1.0-SNAPSHOT.jar。我将第一个文件传输到远程计算机并运行命令:

hadoop jar hadoop my-appy-1.0-SNAPSHOT.jar  /user/bli1/wordcount/input /user/bli1/wordcount/output

我也尝试过:

hadoop my-appy-1.0-SNAPSHOT.jar WordCount /user/bli1/wordcount/input /user/bli1/wordcount/output

我不确定为什么会收到此错误:

错误:无法找到或加载主类 my-appy-1.0-SNAPSHOT.jar

enter image description here

pom.xml:

  <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<excludes>
<exclude>org.hamcrest:*</exclude>
<exclude>org.mockito:*</exclude>
<exclude>org.objenesis:*</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/LICENSE</exclude>
<exclude>META-INF/license</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.mycompany.app.WordCount</Main-Class>
<Build-Number>1</Build-Number>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

最佳答案

打开您的 *.jar 文件并检查它的 MANIFEST.mf 文件。它应该包含“Main-Class”行,其中包含具有“public static main()”方法的类。如果没有“Main-Class”,请自行添加

此链接将帮助您执行此操作:https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

关于java - 在 Jar 中使用第 3 方依赖项运行映射缩减作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29333702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com