问题
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...
回答1:
In IntelliJ 12.1.4 I went through Settings --> Maven --> Importing
and made sure the following was selected:
- Import Maven projects automatically
- Create IDEA modules for aggregator projects
- Keep source...
- Exclude build dir...
- Use Maven output...
- Generated souces folders: "detect automatically"
- Phase to be...: "process-resources"
- Automatically download: "sources" & "documentation"
- 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.
回答2:
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
回答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.
This got the dependencies to magically appear.
回答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.
回答5:
I have tried several options, but this one finally solved my problem. I re-imported the project by following these steps in IntelliJ:
- File -> New -> Project From Existing Repositories
Choose your project from 'Select File or Directory to Import'
In the next screen choose 'Import Project From external model', and choose 'Maven.
- In the next step, click the checkbox 'Import Maven projects automatically', (that solved my problem)
- Finish up by choosing profiles if necessary
For me re-importing maven projects did not solve the issue for an existing projects.
回答6:
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.
回答7:
To me the problem what that I had to check the box "Import maven projects automatically" under Setting> Maven>Importing
回答8:
Just encountered the same problem after IntelliJ update. My fix: right click on the project, then maven -> reimport.
回答9:
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:

回答10:
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.
回答11:
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
回答12:
- close intelliJ
- open the same project
- when the project loads, at the lower right u can see a pop up saying "non managed pom.xml file found", if u click on it a new pop up will come, saying add maven project, click on it, and done.
回答13:
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.
回答14:
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.
回答15:
In my case,i expanded the maven projects panel on the right side, clicked + and added the project. Then it worked.

回答16:
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)
回答17:
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.
回答18:
<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
回答19:
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.
回答20:
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)
回答21:
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.
回答22:
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:
- Maven home directory =
- User settings file =
- Local repository =
回答23:
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
回答24:
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)
回答25:
go to External libraries and remove them all libraries that says root after click on reimport all project
来源:https://stackoverflow.com/questions/15727356/intellij-idea-cannot-resolve-anything-in-maven