IntelliJ Idea not resolving Mockito and JUnit dependencies with Maven

Try View -> Tool Windows -> Maven projects, then click the blue icon in the top left of the tool window (Reimport all Maven projects). You should be able to find the dependencies in the project view, under external libraries.

If this does not work, there is probably something wrong with your maven config (pom.xml). Try mvn clean install from the command line see if it gives any errors.


I solved this problem by adding mockito to module I used. Just go to File -> Project structure and in Modules add mockito to your selected module - the one in which you use mockito (usually Test).


My IDE was not resolving JUnit & Mockito dependencies. Tried reimport in IntelliJ and mvn clean install multiple times which didn't help. Reimport worked for me, but with the following steps.

Please be aware that you will lose any run configurations that you have created.

  1. Close IntelliJ
  2. Go to Project Folder and remove .idea folder (rm -rf ./idea)
  3. Import Maven project again (You will need to add back any run configurations that were deleted)