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.
To avoid IntelliJ IDEA replacing imports with * , you need to configure the Class count to use import with '*' and Names count to use static import with '*' preferences: Go to Preferences > Editor > Code Style > Java.
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.
Project Structure (Ctrl+Alt+Shift+S).
Modules
Select your problem module.
Change tab on top of window "Sources".
Remove unwanted source roots. Keep one and add src and test source roots in this root.
File
-> Invalidate Caches/Restart
And
Build your project
IntelliJ has issues in resolving the dependencies. Try the following:
Run this command in your project console:
mvn idea:idea
Done. Had this issue many times. Tried 'Invalidate Cache & Restart' and all other solutions. Running that command works perfect to me. I'm currently using IntelliJ 2019.2, but this also happened in previous versions and solution worked as well.
Check your module dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With