Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Idea 14: cannot resolve symbol spark

I made a dependency of Spark which worked in my first project. But when I try to make a new project with Spark, my SBT does not import the external jars of org.apache.spark. Therefore IntelliJ Idea gives the error that it "cannot resolve symbol". I already tried to make a new project from scratch and use auto-import but none works. When I try to compile I get the messages that "object apache is not a member of package org". My build.sbt looks like this:

name := "hello"
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies += "org.apache.spark" % "spark-parent_2.10" % "1.4.1"

I have the impression that there might be something wrong with my SBT settings, although it already worked one time. And except for the external libraries everything is the same... I also tried to import the pom.xml file of my spark dependency but that also doesn't work. Thank you in advance!

like image 452
Giselle Van Dongen Avatar asked Aug 28 '15 07:08

Giselle Van Dongen


4 Answers

This worked for me->

name := "ProjectName"
version := "0.1"
scalaVersion := "2.11.11"

libraryDependencies ++= Seq(
  "org.apache.spark" % "spark-core_2.11" % "2.2.0",
  "org.apache.spark" % "spark-sql_2.11" % "2.2.0",
  "org.apache.spark" % "spark-mllib_2.10" % "1.1.0"
)
like image 54
Yash P Shah Avatar answered Oct 17 '22 01:10

Yash P Shah


I use

scalaVersion := "2.11.7"

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.4.1"

in my build.sbt and it works for me.

like image 40
Tobi Avatar answered Oct 17 '22 01:10

Tobi


I had a similar problem. It seems the reason was that the build.sbt file was specifying the wrong version of scala.

If you run spark-shell it'll say at some point the scala version used by Spark, e.g.

Using Scala version 2.11.8

Then I edited the line in the build.sbt file to point to that version and it worked.

like image 2
JARS Avatar answered Oct 16 '22 23:10

JARS


Currently spark-cassandra-connector compatible with Scala 2.10 and 2.11.

It worked for me when I updated the scala version of my project like below:

ThisBuild / scalaVersion := "2.11.12"

and I updated my dependency like:

libraryDependencies += "com.datastax.spark" %% "spark-cassandra-connector" % "2.4.0",

If you use "%%", sbt will add your project’s binary Scala version to the artifact name.

From sbt run:

sbt> reload
sbt> compile
like image 2
cell-in Avatar answered Oct 17 '22 01:10

cell-in