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
For me, what did the trick was to add the dependencies in File > Project Settings > Modules > Dependencies.
After installing IntelliJ IDEA on a new computer I found myself with the same issue.
I had to update the remote maven repository. (Settings > Maven > Repositories
)
Both local and remote repos needed to be updated. The remote one wasn't updated ever before this. After a restart everything worked fine. You might have to reimport your project.
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. Afterwards Maven -> Reimport
finished it off.
Cache is causing problems! Make sure to do the following:
In your terminal, go to project/module:
mvn clean install
In your IntelliJ:
File > Invalidate Caches > Invalidate
Right click on project/module > Maven > Reimport
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:
myProject
module1
module2
module3
BUT, my (simplified) pom structure is like this:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>devs</groupId>
<artifactId>myProject</artifactId>
<version>0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myProject</name>
<modules>
<module>module1</module>
<module>module2</module>
<modules>
<profiles>
<profile>
<id>CompleteBuildProfile</id>
<modules>
<module>module3</module>
</modules>
</profile>
</profiles>
</project>
To fix this, I modified the root <modules>
element to add in module3 temporarily.
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<modules>
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. Click No
.
Bam! Done. Module3 works and I can run my Integration tests from IntelliJ again :D
Ran into the "same" issue some days ago. It might not be related as my issue was more specific to Spring boot but as I was struggling with it and tried every solution on this post I'm going to share my experience.
What I was trying to do is to add one of my spring boot app into another project as a maven dependency. The dependency was resolved but I couldn't access my classes.
When no packaging is declared, Maven assumes the default packaging is JAR. The JAR generated by the Spring Boot Maven Plugin overrides the default one generated by Maven.
The solution was:
The solution that we found is to generate another JAR which will be used as a dependency to be imported from other projects.
The full article which helped me solve my issue.
Hope it helps someone.