Reputation: 1844
I just imported 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 are no exceptions in idea.log...
Upvotes: 172
Views: 297011
Reputation: 1111
I had to do something similar
Upvotes: 1
Reputation: 1
Inside Intellij settings -> maven -> imports in the Use Maven3 to import project VM options for importer: -Xmx512m
This worked for me.
Upvotes: 0
Reputation: 1
You can go to your Maven directory(.m2) to delete all dependencies that have errors and show red, and then click refresh in Maven of IDEA. The error may be caused by incomplete downloading of dependencies due to network reasons
Upvotes: -1
Reputation: 86
Search and remove .iml file, it resolved the problem for me. Hope this helps someone.
Upvotes: 1
Reputation: 1637
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
Upvotes: 162
Reputation: 9
After a long trial and error, unchecking the pom.xml from ignore list worked for me.
Upvotes: 1
Reputation: 1318
If nothing works then you can just delete .idea directory and re-import the project :)
Upvotes: 1
Reputation: 567
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!!
Upvotes: 1
Reputation: 510
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.
Upvotes: 0
Reputation: 1912
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:
Worked like a charm for me, good luck! :wave:
btw I'm using IntelliJ IDEA Ultimate 2020.2 on a Mac.
Upvotes: 1
Reputation: 71
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.Upvotes: 6
Reputation: 901
go to External libraries and remove them all libraries that says root after click on reimport all project
Upvotes: 0
Reputation: 2140
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)
Upvotes: 1
Reputation: 11
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
Upvotes: 1
Reputation: 1293
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:
Upvotes: 0
Reputation: 1901
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.
Upvotes: 0
Reputation: 3284
In my case,i expanded the maven projects panel on the right side, clicked + and added the project. Then it worked.
Upvotes: 1
Reputation: 1
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)
Upvotes: 0
Reputation: 697
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.
Upvotes: 1
Reputation: 2906
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
Upvotes: 4
Reputation: 8563
<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
Upvotes: 0
Reputation: 3249
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.
Upvotes: 0
Reputation: 31
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.
Upvotes: 1
Reputation: 171
I have tried several options, but this one finally solved my problem. I re-imported the project by following these steps in IntelliJ:
Choose your project from 'Select File or Directory to Import'
In the next screen choose 'Import Project From external model', and choose 'Maven.
For me re-importing maven projects did not solve the issue for an existing projects.
Upvotes: 10
Reputation: 1090
3 Simple Steps: IntelliJ 14:
File>settings>Build,execution,deployment>Build tools
Select Maven
Maven home directory: C:/Program Files/apache-maven-3.3.3 (your equivalent location)
Upvotes: 0
Reputation: 1246
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.
Upvotes: 2
Reputation: 1251
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.
This got the dependencies to magically appear.
Upvotes: 53
Reputation: 2703
I had the very same problem as author!
To solve my issue I had to add Maven Integration Plugin: File | Settings | Plugins
Like this:
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:
Upvotes: 4
Reputation: 1492
Just encountered the same problem after IntelliJ update. My fix: right click on the project, then maven -> reimport.
Upvotes: 7