Intellij idea cannot resolve anything in maven

Solution 1:

I have encountered this problem,idea cannot download all dependent jar packages using maven,i just tried the following operations:

 mvn -U idea:idea

then all the dependent jar packages are download from the maven repository

Please note that idea plugin is retired

Solution 2:

In IntelliJ 12.1.4 I went through Settings --> Maven --> Importing and made sure the following was selected:

  1. Import Maven projects automatically
  2. Create IDEA modules for aggregator projects
  3. Keep source...
  4. Exclude build dir...
  5. Use Maven output...
  6. Generated souces folders: "detect automatically"
  7. Phase to be...: "process-resources"
  8. Automatically download: "sources" & "documentation"
  9. Use Maven3 to import project
    • VM options for importer: -Xmx512m

This took me from having a lot of unresolved import statements to having everything resolved. I think the key here was using Maven3 to import project... Hopefully this helps.

Solution 3:

I ran into this issue when using IntelliJ 14's bundled Maven 3 instance.

I switched to using my own local Maven instance, via:

Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Maven Home Directory

Then added the path to my locally installed instance.enter image description here

This got the dependencies to magically appear.

enter image description here

Solution 4:

I was also getting this error because the project imported main and test folders as modules. Click on Project --> Press F4 --> In Module settings, remove main and test folders and the make the project again. Problem will be resolved.

Solution 5:

I have tried several options, but this one finally solved my problem. I re-imported the project by following these steps in IntelliJ:

  1. File -> New -> Project From Existing Repositories
  2. Choose your project from 'Select File or Directory to Import'

  3. In the next screen choose 'Import Project From external model', and choose 'Maven.

  4. In the next step, click the checkbox 'Import Maven projects automatically', (that solved my problem)
  5. Finish up by choosing profiles if necessary

For me re-importing maven projects did not solve the issue for an existing projects.