On creating a Scala project in IntelliJ, the build.sbt file shows error "Cannot resolve symbol name". When I created a "Hello World" Scala Object, in spite of the error in sbt file, the program ran successfully.
When I added a dependency in the build.sbt for Spark core, it showed "Cannot resolve symbol libraryDependencies", and in the Scala Object, when I added an import for SparkContext import org.apache.spark.SparkContext
, it gave "Cannot resolve symbol apache".
I went through the below related post:
IntelliJ inspection gives "Cannot resolve symbol" but still compiles code
and attempted "Invalidate Cache" but it did not resolve the issue.
I also tried deleting the IDEA directory and reimporting the project as below:
- Closed IntelliJ.
- Went to the project folder and delete the .idea directory.
- Opened IntelliJ.
- Imported the project again by clicking on File>>New>>Project from existing sources.
However, this too did not resolve the issue.
Also, I tried using a lower version of Scala which did not resolve the issue.
Below are the contents of the build.sbt file:
name := "ScalaApp"
version := "0.1"
scalaVersion := "2.12.12"
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.4.3"
What can be the issue that it shows these errors in build.sbt and despite that the Scala hello world runs fine but not when I add another dependency in build.sbt and include import in the Scala class?
Thanks