Intellij idea cannot resolve anything in maven

MavenIntellij IdeaMaven 3

Maven Problem Overview


I'm new to Intellij Idea, i just import a project with pom.xml, but the ide didn't resolve anything in maven dependencies.

Anything defined in pom.xml dependencies when import in code raise an error cannot resolve symbol xxxxx

But mvn install will work, i try import the dependencies in Project Settings/Libraries in .jar files, then it works, but could the ide resolve libraries defined in pom.xml? i don't want to do that everytime.

Additionnal info:

IDEA version: 12.0.3, OS : windows 7, reimport does not work, maven version : 3.0.4, maven dependencies does not exists under Exernal Libraries.

there is no exceptions in idea.log...

Maven Solutions


Solution 1 - Maven

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 - Maven

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 - Maven

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 - Maven

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 - Maven

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.

Solution 6 - Maven

Just encountered the same problem after IntelliJ update. My fix: right click on the project, then maven -> reimport.

Solution 7 - Maven

To me the problem what that I had to check the box "Import maven projects automatically" under Setting> Maven>Importing

Solution 8 - Maven

  1. Close IntelliJ
  2. Open the same project
  3. When the project loads, at the lower right you can see a pop up saying non-managed pom.xml file found, if you click on it a new pop up will come, saying add as maven project, click on it, and done.

Solution 9 - Maven

I was getting this error because my project was not setup correctly. It had imported main and test folders as modules. When I deleted the 2 modules (but retained them as source and test folders), my code started compiling correctly.

Solution 10 - Maven

I had the very same problem as author!

To solve my issue I had to add Maven Integration Plugin: File | Settings | Plugins

Like this:

Maven Integration Plugin

After that Intellij downloaded all the dependencies from pom.xml file.

Now if I want to create a project based on maven model, I just choose Open on the first Intellij window and choose the pom.xml file:

enter image description here

Solution 11 - Maven

I had empty settings.xml file in Users/.../.m2/settings.xml. When i added

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  
</settings>

all dependicies were loaded

Solution 12 - Maven

If you imported your maven project in IntelliJ and there are errors because of maven imports not getting resolved, it maybe because of the custom maven settings.xml you may be using. I tried overriding it in the Intellij default maven settings but it did not help. Finally I had to keep it in ~/.m2/settings.xml and then IntelliJ finally honored it.

Solution 13 - Maven

try maven command shared below it would work!

mvn idea:idea

Solution 14 - Maven

In Settings -> Maven -> Repositories only some repositories configured in my settings displayed.

Workaround

It is probably a bug (Idea 13.1.5 Ultimate). It helped me to switch the mirrors. The one that was not showing up to the top.

Solution 15 - Maven

With intelliJ 16.1.4 I had the same issue. You should have a look at the Event Log, because it told me "Non-managed pom.xml file found:..." I then clicked on it and the problem was solved.

Solution 16 - Maven

It seems to me that solutions to this problem is plenty and all look a bit like magic. For me, invalidation of caches, re-importing or anything else already mentioned was not working. The only thing that helped was (without re-import) go to Maven settings, uncheck automatic importing and re-check it back.

enter image description here

Solution 17 - Maven

In my case,i expanded the maven projects panel on the right side, clicked + and added the project. Then it worked.

https://i.stack.imgur.com/GC6wt.png" width="300" height="300">

Solution 18 - Maven

If you have any dependencies in pom.xml specific to your organisation than you need to update path of setting.xml for your project which is by default set to your user directory in Ubuntu : /home/user/.m2/settings.xml -> (change it to your apache-maven conf path)

Update Setting.xml file Intellij

Solution 19 - Maven

For me to sort this issue I had to go to Build, Execution, Deployment -> Build Tools -> Maven -> Importing and set JDK for import to JAVA_HOME! Then Reload all maven projects from the maven settings. All imports now work!!

Solution 20 - Maven

After a long trial and error, unchecking the pom.xml from ignore list worked for me.

enter image description here

Solution 21 - Maven

3 Simple Steps: IntelliJ 14:

  1. File>settings>Build,execution,deployment>Build tools

  2. Select Maven

  3. Maven home directory: C:/Program Files/apache-maven-3.3.3 (your equivalent location)

Solution 22 - Maven

Keep in mind that IntelliJ adds your local Maven installation's classes to its own classpath, so keep it up to date.

In my case IntelliJ tried to call method org.eclipse.aether.util.ConfigUtils.getFloat(). This caused a java.lang.NoSuchMethodError, because my years old Maven version didn't contain this method yet. Due to the exception IntelliJ stopped resolving dependencies.

After updating Maven, you have to change the "Maven home directory" setting in "Build, Execution, Deployment" -> "Maven". After that you must restart IntelliJ, because the classpath of IntelliJ's JVM won't change while running.

It took me some time to solve this problem, as I didn't expect IntelliJ to use the classes of my local Maven installation. I thought it uses it's own bundled JARs. So hopefully this information is helpful for others.

Solution 23 - Maven

<option name="workOffline" value="true" /> in workspace.xml is not your friend. Advise to check this before deleting your .idea (which has a lot of useful settings you probably don't want to lose)

It's a maven workspace.xml setting

Solution 24 - Maven

there's an issue with the bundled Maven version. as someone previously suggested I switched to my own Maven installation and dependencies magically worked (IntelliJ 2018.3)

Solution 25 - Maven

I have just had this issue when adding <dependency>...</dependency> elements to a <profile>. I just found that if I add (insert) the unresolved dependency elements to the <dependencies> element, the dependencies are downloaded from the maven repository; I can then remove the dependency element from the dependencies element.

Solution 26 - Maven

Using default maven (which comes with IntelliJ) also could create this problem. So configure the maven which you have installed.

This can be done from: File -> Settings -> Build, Execution, Deployment -> Maven

Update following settings according to your maven installation:

  1. Maven home directory =
  2. User settings file =
  3. Local repository =

Solution 27 - Maven

Okay I was facing this problem for days. Was trying to import POI library and Simple JSON library, I tried all the proposed answers and solution nothing worked. In the end the solution for my case was quite simple

I just needed to add the following to my module-info.java file after putting the dependencies in my POM file :

 requires poi.ooxml;
 requires poi;
 requires json.simple;

so I think because my project was in a package in a module I had to do this to let the system knows that these imported libraries will be used. so simple put the library name after require in your module-info.java file

Hope it works for you

Solution 28 - Maven

go to External libraries and remove them all libraries that says root after click on reimport all project

enter image description here

Solution 29 - Maven

I tried all of the other suggestions in this thread and nothing worked - however I found this thread from the Jetbrains site and their solution did work for me. I hope it helps some of you as well. Specifically this suggestion worked:

  • Close the IDE
  • Delete the /Users/yourname/Library/Caches/IntelliJIdeaXXX/ directory (whatever your version is)
  • Start IDE and re-import project from scratch as Maven project

Worked like a charm for me, good luck! :wave:

btw I'm using IntelliJ IDEA Ultimate 2020.2 on a Mac.

Solution 30 - Maven

Unfortunately I ran into the same issue and I was head scratching why this is happening. I almost tried everything on this page and but none worked for me.

So , I tried to go the root of this problem; and the problem was (Atleast for me) that I was trying to open a maven project but pom file was not identified. So right clicking on the pom file and choosing "add as maven project" and then right clicking on the project -> Maven -> Reimport did all the magic for me :)

Hopefully this can be helpful for someone.

Solution 31 - Maven

If nothing works then you can just delete .idea directory and re-import the project :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBurstView Question on Stackoverflow
Solution 1 - MavenranpengcoderView Answer on Stackoverflow
Solution 2 - MavenMCPView Answer on Stackoverflow
Solution 3 - MavenConor SvenssonView Answer on Stackoverflow
Solution 4 - MavenAnuragView Answer on Stackoverflow
Solution 5 - MavencaytekinView Answer on Stackoverflow
Solution 6 - MavenJarosław JaryszewView Answer on Stackoverflow
Solution 7 - MavenLaura LiparuloView Answer on Stackoverflow
Solution 8 - Mavenhulesh chandraView Answer on Stackoverflow
Solution 9 - MavenvishalView Answer on Stackoverflow
Solution 10 - MavenAnatolii StepaniukView Answer on Stackoverflow
Solution 11 - MavenValeriy K.View Answer on Stackoverflow
Solution 12 - MavensdmView Answer on Stackoverflow
Solution 13 - MavenibrahimgunesView Answer on Stackoverflow
Solution 14 - MavenAmio.ioView Answer on Stackoverflow
Solution 15 - MavenLuka HaleView Answer on Stackoverflow
Solution 16 - MavenMartin DView Answer on Stackoverflow
Solution 17 - MavenMuratView Answer on Stackoverflow
Solution 18 - MavenPukhraj soniView Answer on Stackoverflow
Solution 19 - Mavensean le royView Answer on Stackoverflow
Solution 20 - MavenSravan GajulaView Answer on Stackoverflow
Solution 21 - MavenzillaniView Answer on Stackoverflow
Solution 22 - MavenfishboneView Answer on Stackoverflow
Solution 23 - MavenycompView Answer on Stackoverflow
Solution 24 - MavenAlejandro GarcíaView Answer on Stackoverflow
Solution 25 - MavenJL_SOView Answer on Stackoverflow
Solution 26 - Mavenhorizon7View Answer on Stackoverflow
Solution 27 - MavenAbdussalamView Answer on Stackoverflow
Solution 28 - MavenAndy QuirozView Answer on Stackoverflow
Solution 29 - MavenMark MadejView Answer on Stackoverflow
Solution 30 - MavenajainView Answer on Stackoverflow
Solution 31 - MavenVishal MaralView Answer on Stackoverflow