Maven Dependency not recognized by IntelliJ
Hello,
I've been struggling for a few hours on a dependency problem on my maven project. As I'm trying to debug my program, I'm using IntelliJ built in functionality.
Unfortunately it doesn't work. My IntelliJ wouldn't recognize the following dependency :
java: package org.junit.jupiter.api does not exist
Here is my pom.xml dependencies
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
The output
java: package org.junit.jupiter.api does not exist
is appearing when I'm importing this in my tests :
import org.junit.jupiter.api.Test;

It also works properly on my GitHub workflow, it even update my CodeCov badge and shows the percentage as expected.
I really tried everything on IntelliJ, from reloading the maven project, to reimporting the project using the pom.xml or even Invalidate caches -> Clear file system cache and local history
I hope someone will be able to help me, have a good day.
Please sign in to leave a comment.
If you haven't already please try following:
If the issue persists, please share a screenshot of the entire IDE window showing:
Also, if possible please provide a sample project for reproduction and your IDE logs (Help > Collect Logs and Diagnostic Data).
You can zip the files and upload them securely here: https://uploads.jetbrains.com, just provide the uploaded file ID. Thanks!
Thank you for your answer, I ended up deleting the whole project and re-pulled it from my GitHub repo and it worked perfectly fine.
I didn't think about deleting the idea folder and iml files, but it does sound like something that would have been better than just re-pulling the whole project ahah...
Have a good day !
After going crazy for a few hours, the trick was one of:
- "repair ide"
- "unlink and re-import as maven project"
-"remove all /.idea and start again from fresh import"
Very annoying, these things have happened before and really hard to debug where the issue is, as command line maven works as expected.
Unfortunately I have a similar (same?) problem and steps listed above don't help:
mvn clean install works
source code editor does let me drill down into org.junit.jupiter.api
running any test class shows:
"java: package org.junit.jupiter.api does not exist"
Other projects build in the same manner do work without issues.
Screenshots of the dependencies (project and maven) included.
A sample project is not possible - as I wrote I have problems with a specific project.

I have just deleted the project physically from the local file system, cloned it again, imported into IDEA and it works now.
Invalidating caches, reparing IDE, unlinking and linking Maven did not help.
Removing .idea subdirectory didn't help.
Only physically removing the project did help.
Did you check the ignored packages in the auto import settings?
This took me so long to fix that I had to take the extra time to comment on this thread. Only physically removing it and reimporting from github worked for me as well.
Invalidating caches, reparing IDE, unlinking and linking Maven did not help.
Removing .idea subdirectory didn't help.
In my case I had to specifically configure to the maven compiler plugin the source and target Java version. Example:
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
Try to download sources, it worked out for me:
right click pom > maven > download sources
and then reload and recompile project
An update to my previous comment. My problem was that the parent Pom had release as a version. The new IntelliJ comes with maven 3.9 which treats it as an error and does not download the dependencies. To overcome it I had to set the maven to an older version (example 3.6) from the setting menu.
Typically, if Maven processes a dependency correctly, but IDEA does not, that indicates a de-sync between Maven's and IDEA's Project Models.
In most cases this de-sync can be ironed out by running a Maven Sync:
Unfortunately, if de-sync is significant or IDEA's Project Model is corrupted, it has to be fully reset.
To do so:
pom.xml
→ Open as ProjectIf the issue persists, it's best to report it by submitting a YouTrack Issue or a Support Ticket.
Hello Roman Vatagin
These last days, I was going through the same issue, in my case running the below maven command into an IntelliJ terminal fixed the dependencies desync:
mvn versions:resolve-ranges -DprocessDependencies=false
Ivan Y Avila Thank you for reporting this!
Note that the latest version of IDEA (2024.3) provides the “Reload” option, that should allow you avoid running the Goal via command line:
I would also appreciate if you could share more details about the specific changes that the Sync is not picking up.
Once I'll be able to reproduce the issue, I can send it to the developers to get it addressed.
This is crazy still happening.
I am adding a dependency, and dependency is listed in project structure but the file reference looks red, although file actually exists.
Reloading all maven projects is not fixing it. Repairing ide and rescanning project indexes fixes it sometimes.
I am considering switching back to Eclipse just because of this!
Serkan Erdur Could you please share more details about how the dependency is declared and the Project's structure?
When the issue occurs is the dependency listed under Project Tool Window → External Libraries?
As a workaround try the following:
pom.xml
→ Open as ProjectI think I found a workaround and have more idea how to reproduce it.
To reproduce:
1. Add a dependency to pom but dependency should not be in the local maven repository at that time
2. Click “reload all maven projects incrementally” button.
Workaround solution:
After adding the dependency run a maven compile before clicking “reload all maven projects incrementally” button. Manual compile will make dependency downloaded to local repository hence the issue will not happen.
Serkan Erdur Thank you for sharing the details!
The issue, however, does not seem to reproduce in my environment.
Could you confirm you are using the latest version of IDEA (2024.3.2.2)?
Does the issue reproduce consistently for you?
Could you please share the IDEA logs?
I am using 2024.2.3 and cannot update it myself, version is managed by my company.
I could reproduce it last 2 times I tried.
Serkan Erdur I've tested with the 2024.2.5 - I'm not seeing the issue either.
Would you be able to share the affected Project or its POM(s) (preserving the directory structure) for further investigation?
Similar problem with
IntelliJ IDEA 2024.3.2.2 (Ultimate Edition)
Build #IU-243.23654.189, built on January 29, 2025
Build ok on maven but fail in IntelliJ with package not found. I added the project with the missing package as module but the error persists.
Could please try the following and let me know if it has any affect on the issue?
Shift
twiceRegistry
” in the Search Everywhere windowmaven.sync.refresh.resolved.artifacts
keyEnabling maven.sync.refresh.resolved.artifacts seems to fixed my issue!
Serkan Erdur In such case, this is likely the issue described in IDEA-358024.
Fix for it has already been developed and will be available in both upcoming version of IDEA (2025.1) and via an update for 2024.3.
I do not think it is the same issue because this is not how it behaves for me. For me old dep is gone and, new dep does not appear.
"Actual result: The old dependency remains in the "External Libraries" view."
Serkan Erdur If the
maven.sync.refresh.resolved.artifacts
Registry Key helped - this is most likely the same issue.The symptoms may be a little different, but the root cause if likely the same.
In my case
maven.sync.refresh.resolved.artifacts
was checked. It looks like it is working fine now after some ‘repair IDE’ and restarts. Sorry but I don't know exactly the moment it started to working fine.Walter Mourao Let's keep monitoring the situation!
Let me know if the issue comes back at any point - if it does, we can investigate it further.