Why does IntelliJ give me "Package doesn't exist" error?
Just reimport didn't work. Following worked for me.
File -> Invalidate Caches /Restart
Then
Build -> Rebuild Project
That will reimport maven project.
Note : You need to invalidate the cache AND ALSO rebuild the project.
I tried to "Maven > Reimport" but the only thing that actually fixed it was to close the project, delete the .idea directory, and reopen the project.
Right click your project / Maven (at bottom) / Reimport
Edit, much later: I also saw this happen much more frequently when I had the Clover plugin installed. Drop that plugin like a bad habit!
None of the 13 existing answers worked for me. However, I could resolve the issue by first removing all modules:
- open
File
>Project Structure...
, - go to
Modules
tab, - select all modules and press the remove button,
then removing all remaining Maven modules from Maven
tool window:
- select all modules,
- right click on them,
- press
Remove projects
,
and then adding them again in Project
tool window:
- right click on root
pom.xml
, - press
Add as Maven project
,
now unignoring any ignored modules from Maven
tool window:
- select all ignored (grey) Maven modules,
- right click on them,
- press
Unignore
,
and finally rebuilding using Build
> Rebuild project
. This assumes that a mvn clean install
already happened.