Intellij Inspection Gives "Cannot Resolve Symbol" But Still Compiles Code

IntelliJ inspection gives Cannot resolve symbol but still compiles code

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.

IntelliJ inspection gives Cannot resolve symbol but still compiles code

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.

Intellij Cannot resolve symbol on import

There can be multiple reasons for this. In my case it was wrong source root issue. Invalidate caches didn't work along with other solutions.

Check your module source roots.

  1. Project Structure (Ctrl+Alt+Shift+S).

  2. Modules

  3. Select your problem module.

  4. Change tab on top of window "Sources".

  5. Remove unwanted source roots. Keep one and add src and test source roots in this root.

Cannot resolve symbol in Intellij IDEA

You need to add your external libraries/classes under dependencies in order for IDEA to see them when doing code analysis/autocomplete.

IntelliJ inspection gives Cannot resolve symbol but still compiles code

First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.

In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.

Maven dependency “Cannot resolve symbol VectorAssembler'” in IntelliJ IDEA

You specified mllib dependency as runtime - this means that dependency is required for execution, but not for compilation, so it won't be put into classpath for compiling your code. See this blog post for description of of different scopes available in Maven.

Replace all spark dependencies (mllib, core, sql) with just single dependency (also remove hadoop dependencies):

    <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_${spark.scala.version}</artifactId>
<version>${spark.version}</version>
<scope>provided</scope>
</dependency>

where variables are defined as

  <properties>
<spark.version>3.0.1</spark.version>
<spark.scala.version>2.12</spark.scala.version>
</properties>


Related Topics



Leave a reply



Submit