Intellij Cannot resolve symbol on import Intellij Cannot resolve symbol on import java java

Intellij Cannot resolve symbol on import


you can try invalidating the cache and restarting intellij, in many cases it will help.

File -> Invalidate Caches/Restart


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.


IntelliJ has issues in resolving the dependencies.Try the following:

  1. Right click on pom.xml -> Maven -> Reimport
  2. Again Right click on pom.xml -> Maven -> Generate sources and update folders