I have a project in IntellijIDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.
The project builds fine on command line if I do "mvn install". When I open any of the code files in the IDE though it says all the classes handled by Maven dependencies aren't recognized - as it would for a normal project if I never added the required JARs to the build path.
I know in my Eclipse Maven projects (rather than IntelliJ) it usually shows an extra directory on the left which says "Maven Dependencies" and lists the JARs pulled in via maven. I don't see that here. What am I doing wrong?
Here's what my screen looks like:
I was running into similar issues. For me it ended up being that I was importing the project incorrectly. I had been doing
What solved my maven problems was to do
Looks like there are several, valid reasons why intelliJ would ignore a pom file. None of the previous answers worked in my case, so here's what did work, in case someone else runs into this issue:
In this example, module3 was being completely ignored by IntelliJ. The pom.xml in that directory wasn't even being treated as a maven pom.
My project structure is like this:
BUT, my (simplified) pom structure is like this:
To fix this, I modified the root
<modules>
element to add in module3 temporarily.Next re-import the root pom, and IntelliJ will add the module. When that's done, revert the pom. IntelliJ will ask if you also want to remove
module3
from the project structure. ClickNo
.Bam! Done. Module3 works and I can run my Integration tests from IntelliJ again :D
A simple reimport and/or update of the repositories via Intellij did not do the trick for me.
Instead I had to delete the complete
~/.m2/repository
directory and let maven sort everything out by itself. AfterwardsMaven -> Reimport
finished it off.In my case the problem was that the project was in maven2 while intellj was configured for maven3. Switching to maven2 in settings solved the problem
This also happened to me after upgrading Intellij to 1.4.15. I tried to re-import the whole project with same result, but enabling Maven Auto Import did the tricks.
The problem was caused for me by selecting the project directory to be Imported when first starting IntelliJ rather than the
pom.xml
file for the project.Closing the problem project and then following the Import process again but choosing the
pom.xml
resulted in a fully working project in the IDE.