IDEA上的4種Artifacts組合


結論:

1,簡單的hadoop項目(Maven)Create JAR from Modules頁面中,最簡單的方式為Main Class為空,選擇extract to the target JAR。這樣不會指定主類,不會生成MANIFEST.MF文件。

2,Main Class會在jar包內的MANIFEST.MF中指定主類,執行jar包時不可以另外指定主類

3,選項extract to the target JAR(提取到目標JAR)不會在MANIFEST.MF文件中鏈接依賴的jar包(整包)。

選項copy to the output directory and link via manifest(復制到輸出目錄和清單鏈接)會將依賴的jar包放在目錄中,在MANIFEST.MF文件中以鏈接的形式引用jar包(散包)。

 

 

Create JAR from Modules頁面

 

NO Main Class

extract to the target JAR

hadoop jar WordCount.jar WordCount input/demo/word.txt output
成功

 

Main Class

extract to the target JAR

 

hadoop jar WordCount.jar input/demo/word.txt output
成功

 

NO Main Class

copy to the output directory and link via manifest

 

失敗
Exception in thread "main" java.lang.ClassNotFoundException:
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

hadoop jar WordCount.jar WordCount input/demo/word.txt output
刪除MANIFEST.MF文件成功

 

Main Class

copy to the output directory and link via manifest

hadoop jar WordCount.jar input/demo/word.txt output
成功

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM