我对此做了一些研究,似乎是由于某些版本不匹配。我试图解决这个问题很长一段时间,并不确定修复。任何帮助是极大的赞赏。
这是我的pom.xml
<properties>
<scala.version>1.6.2</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
<scope>compile</scope>
</dependency>
</dependencies>
这是我正在使用的maven scala插件配置:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>2.11.8</scalaVersion>
</configuration>
</plugin>
异常追踪:
--- 2017-09-06 09:54:21,676 INFO SparkUI: Started SparkUI at http://10.222.159.160:4040 (org.apache.spark.ui.SparkUI)
Exception in thread "main" java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaUniverse$JavaMirror;
at com.abc.ModelTrn$.prepare(ModelTrn.scala:64)
at com.abc.ModelTrn$.main(ModelTrn.scala:20)
at com.abc.ModelTrn.main(ModelTrn.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
答案 0 :(得分:1)
无法重现。我用pom.xml创建了Maven项目。然后我运行标准WordCount。它工作正常。 你能更具体地说明你在做什么吗?
顺便提一下,您是否检查了此例外的先前答案?
java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror