我使用的是Scala 2.11.8,并使用maven在IntelliJ中构建jar文件
我在mobaxterm中运行了我的程序:
/opt/spark-1.6.1-bin-hadoop2.6/bin/spark-submit --class CDR.SQL cdr-maven-1.0-SNAPSHOT.jar
字符串
这是错误消息:
线程"main" java. lang. NoSuchMethodError:Scala. reflect. api. JavaUniverse. runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaUniverse $JavaMirror;在CDR。SQL $。(SQL. scala:24)在CDR处。SQL $。(SQL. scala)处。main(SQL. scala)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.反思NativeMethodAccessorImpl.在sun调用(NativeMethodAccessorImpl.java:62)。反思DelegatingMethodAccessorImpl.在java中调用(DelegatingMethodAccessorImpl.java:43)。lang。反思方法。在org调用(Method.java:498)。ApacheSpark部署SparkSubmit $. org $apache $spark $deploy $SparkSubmit $$runMain(SparkSubmit. scala:731)at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit. scala:181)在org.ApacheSpark部署SparkSubmit $.提交(SparkSubmit. scala:206)在org.ApacheSpark部署SparkSubmit $. main(SparkSubmit. scala:121)在org.ApacheSpark部署SparkSubmit。main(SparkSubmit. scala)
这是我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cdr-maven</groupId>
<artifactId>cdr-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>apache-repo</id>
<name>Apache Repository</name>
<url>https://repository.apache.org/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_2.11</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>1.4.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
型
我该如何解决这个问题?
谢谢你的帮助!
3条答案
按热度按时间f87krz0w1#
你下载了Spark发行版还是自己构建的?
Spark 1.6是默认使用Scala 2.10构建的。请将Scala版本更改为2.10或将Spark更新为2.0,默认情况下,Spark是使用Scala 2.11构建的
mzillmmw2#
将Scala版本更改为2.12.12。这解决了我的问题。还要注意spark核心和spark sql版本应该相同
Mine POM.xml
字符串
slhcrj9b3#
检查版本。
字符串
您使用的是2.15.x版本。