我想知道如果下面的依賴聲明是不夠的,在運行時獲取正確的Maven的依賴性星火API
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/api/java/function/PairFunction
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.api.java.function.PairFunction
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
依賴訪問下面的類
org.apache.spark.api.java.function.PairFunction
錯誤宣稱
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
我運行的.jar像這樣:
hadoop jar target/secondarysortspark-1.0-SNAPSHOT.jar ~/projects/secondarysortspark/secondarysortspark/src/main/java/com/tom/secondarysortspark/data.txt
感謝
你使用這些類進行測試嗎? – Christian
沒有特別說明。我有單元測試運行並通過,當我通過mvn包構建 – Slinky