intellij idea 配置spark环境遇到的两个问题

52次阅读

共计 2195 个字符,预计需要花费 6 分钟才能阅读完成。

在配置 spark 环境的时候出现两个问题:
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>com.spark.zwh</groupId>
<artifactId>spark-test</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<spark.version>2.4.0</spark.version>
<scala.version>2.11</scala.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>

</dependencies>

<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>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

</plugins>
</build>

</project>
其中 <spark.version>2.4.0</spark.version><scala.version>2.11</scala.version> 在 http://spark.apache.org/downl…:groupId: org.apache.sparkartifactId: spark-core_2.11version: 2.4.0 其中 2.11 为 scala 版本,2.4.0 为 spark 版本,只有相互对应的版本才能正确编译,否则会出现各种奇怪问题。
配置好了却发现右键没有新建 scala class 选项,查了很多都没有说到点子上,最终发现
右键项目 -》add frameworks support->scala->ok。现在有 scala class 选项了。

正文完
 0