IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

Solution 1:

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.

Solution 2:

The following trick resolved this issue for me:

  • Right click on the code editor
  • Hover on Maven and expand
  • Click on Reimport

My idea version is 12.0.4

Solution 3:

None of the solutions above worked for me. What did was removing the main.iml file manually and it suddenly worked.

Solution 4:

This was mentioned in another answer to this same question here, but this alone fixes this for me. I do all my builds in a separate terminal, outside of IntelliJ. So the cache's need to have the proper permissions set for the IntelliJ app to read them.

Run it from the project's root folder.

$ mvn -U idea:idea