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

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.


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


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